feat: current nixos generation number

This commit is contained in:
Himadri Bhattacharjee
2025-10-24 17:48:32 +05:30
parent f76f0a7903
commit 2f946add15
2 changed files with 22 additions and 19 deletions

View File

@@ -1,19 +0,0 @@
---
title: "Nix bytes: Check if a package builds with flakes"
date: 2025-10-15T18:11:15+05:30
draft: false
---
- Ensure flakes are enabled
- Create the package derviation file in `./package.nix`
- Add the following to `builder.nix`
```nix
(import <nixpkgs> {}).callPackage ./package.nix { }
```
- Run `nix build` on it
```sh
nix build -f ./builder.nix
```

View File

@@ -41,3 +41,25 @@ nix-channel --update
Further reading: [NixOS discourse](https://discourse.nixos.org/t/command-not-found-unable-to-open-database/3807).
## Check if a package builds (flakes enabled)
- Ensure flakes are enabled
- Create the package derviation file in `./package.nix`
- Add the following to `builder.nix`
```nix
(import <nixpkgs> {}).callPackage ./package.nix { }
```
- Run `nix build` on it
```sh
nix build -f ./builder.nix
```
## Get current NixOS generation number
```sh
readlink /nix/var/nix/profiles/system | cut -d- -f2
```