Compare commits

..

4 Commits

Author SHA1 Message Date
Peder Bergebakken Sundt
eceb2ce4c7 Merge pull request 'base: stabilize system.build.toplevel.outPath for vmVariant' (!105) from no-flake-in-vm into main
Reviewed-on: https://git.pvv.ntnu.no/Drift/pvv-nixos-config/pulls/105
Reviewed-by: Oystein Kristoffer Tveit <oysteikt@pvv.ntnu.no>
2025-06-01 05:29:00 +02:00
Peder Bergebakken Sundt
518008527d Merge pull request 'flake: evaluate devShells with nixpkgs-unstable' (!107) from shell-unstable into main
Reviewed-on: https://git.pvv.ntnu.no/Drift/pvv-nixos-config/pulls/107
Reviewed-by: Oystein Kristoffer Tveit <oysteikt@pvv.ntnu.no>
Reviewed-by: Daniel Lovbrotte Olsen <danio@pvv.ntnu.no>
2025-06-01 05:26:39 +02:00
Peder Bergebakken Sundt
9e82ca3d15 flake: evaluate devShells with nixpkgs-unstable 2025-06-01 00:37:52 +02:00
Peder Bergebakken Sundt
da7cb17f9e base: stabilize system.build.toplevel.outPath for vmVariant
This is done by not depending on the flake itself, allowing the bits of a dirty tree to not affect the hash.
This enables equivalence testing with `just eval-vm bob` and checking if the system closure hash changes or not.
2025-05-31 19:13:33 +02:00
5 changed files with 26 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
{ inputs, ... }: { lib, config, inputs, ... }:
{ {
nix = { nix = {
gc = { gc = {
@@ -21,11 +21,16 @@
** use the same channel the system ** use the same channel the system
** was built with ** was built with
*/ */
registry = { registry = lib.mkMerge [
"nixpkgs".flake = inputs.nixpkgs; {
"nixpkgs-unstable".flake = inputs.nixpkgs-unstable; "nixpkgs".flake = inputs.nixpkgs;
"pvv-nix".flake = inputs.self; "nixpkgs-unstable".flake = inputs.nixpkgs-unstable;
}; }
# We avoid the reference to self in vmVariant to get a stable system .outPath for equivalence testing
(lib.mkIf (!config.virtualisation.isVmVariant) {
"pvv-nix".flake = inputs.self;
})
];
nixPath = [ nixPath = [
"nixpkgs=${inputs.nixpkgs}" "nixpkgs=${inputs.nixpkgs}"
"unstable=${inputs.nixpkgs-unstable}" "unstable=${inputs.nixpkgs-unstable}"

View File

@@ -1,4 +1,4 @@
{ inputs, pkgs, lib, ... }: { config, inputs, pkgs, lib, ... }:
let let
inputUrls = lib.mapAttrs (input: value: value.url) (import "${inputs.self}/flake.nix").inputs; inputUrls = lib.mapAttrs (input: value: value.url) (import "${inputs.self}/flake.nix").inputs;
@@ -26,12 +26,14 @@ in
# workaround for https://github.com/NixOS/nix/issues/6895 # workaround for https://github.com/NixOS/nix/issues/6895
# via https://git.lix.systems/lix-project/lix/issues/400 # via https://git.lix.systems/lix-project/lix/issues/400
environment.etc."current-system-flake-inputs.json".source environment.etc = lib.mkIf (!config.virtualisation.isVmVariant) {
= pkgs.writers.writeJSON "flake-inputs.json" ( "current-system-flake-inputs.json".source
lib.flip lib.mapAttrs inputs (name: input: = pkgs.writers.writeJSON "flake-inputs.json" (
# inputs.*.sourceInfo sans outPath, since writeJSON will otherwise serialize sourceInfo like a derivation lib.flip lib.mapAttrs inputs (name: input:
lib.removeAttrs (input.sourceInfo or {}) [ "outPath" ] # inputs.*.sourceInfo sans outPath, since writeJSON will otherwise serialize sourceInfo like a derivation
// { store-path = input.outPath; } # comment this line if you don't want to retain a store reference to the flake inputs lib.removeAttrs (input.sourceInfo or {}) [ "outPath" ]
) // { store-path = input.outPath; } # comment this line if you don't want to retain a store reference to the flake inputs
); )
);
};
} }

View File

@@ -169,9 +169,9 @@
}; };
devShells = forAllSystems (system: { devShells = forAllSystems (system: {
default = nixpkgs.legacyPackages.${system}.callPackage ./shell.nix { }; default = nixpkgs-unstable.legacyPackages.${system}.callPackage ./shell.nix { };
cuda = let cuda = let
cuda-pkgs = import nixpkgs { cuda-pkgs = import nixpkgs-unstable {
inherit system; inherit system;
config = { config = {
allowUnfree = true; allowUnfree = true;

View File

@@ -1,6 +1,6 @@
set positional-arguments # makes variables accesible as $1 $2 $@ set positional-arguments # makes variables accesible as $1 $2 $@
export GUM_FILTER_HEIGHT := "15" export GUM_FILTER_HEIGHT := "15"
nom := `if [[ -t 2 ]] && command -v nom >/dev/null; then echo nom; else echo nix; fi` nom := `if [[ -t 1 ]] && command -v nom >/dev/null; then echo nom; else echo nix; fi`
nix_eval_opts := "--log-format raw --option warn-dirty false" nix_eval_opts := "--log-format raw --option warn-dirty false"
@_default: @_default:
@@ -26,7 +26,7 @@ run-vm machine=`just _a_machine` *_:
| xargs -d'\n' nix flake update "$@" | xargs -d'\n' nix flake update "$@"
@repl $machine=`just _a_machine` *_: @repl $machine=`just _a_machine` *_:
set -v; NIX_NO_NOM=1 nixos-rebuild --flake .#"$machine" repl "${@:2}" set -v; nixos-rebuild --flake .#"$machine" repl "${@:2}"
@eval $machine=`just _a_machine` $attrpath="system.build.toplevel.outPath" *_: @eval $machine=`just _a_machine` $attrpath="system.build.toplevel.outPath" *_:
set -v; nix eval {{nix_eval_opts}} ".#nixosConfigurations.\"$machine\".config.$attrpath" --show-trace "${@:3}" set -v; nix eval {{nix_eval_opts}} ".#nixosConfigurations.\"$machine\".config.$attrpath" --show-trace "${@:3}"

View File

@@ -1,18 +1,6 @@
{ pkgs ? import <nixpkgs> {} }: { pkgs ? import <nixpkgs> {} }:
let
nixos-rebuild-nom = pkgs.writeScriptBin "nixos-rebuild" ''
if [[ -t 1 && -z "''${NIX_NO_NOM-}" ]]; then
exec ${pkgs.lib.getExe pkgs.nixos-rebuild} -L "$@" |& ${pkgs.lib.getExe pkgs.nix-output-monitor}
else
exec ${pkgs.lib.getExe pkgs.nixos-rebuild} -L "$@"
fi
'';
in
pkgs.mkShellNoCC { pkgs.mkShellNoCC {
packages = with pkgs; [ packages = with pkgs; [
nixos-rebuild-nom
just just
jq jq
gum gum