From ecc37b8fc306c3fcb24715ff36b025efe8e1d4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Mon, 21 Apr 2025 21:01:41 +0200 Subject: [PATCH] refactor(example-vm): don't import nixpkgs This should save on evaluation time. --- example-vm/vm-config.nix | 2 ++ flake-modules/example-vm.nix | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/example-vm/vm-config.nix b/example-vm/vm-config.nix index 1b2b4d0..67e38a7 100644 --- a/example-vm/vm-config.nix +++ b/example-vm/vm-config.nix @@ -31,4 +31,6 @@ # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "24.11"; # Did you read the comment? + + nixpkgs.hostPlatform = "x86_64-linux"; } diff --git a/flake-modules/example-vm.nix b/flake-modules/example-vm.nix index b21085d..e941b37 100644 --- a/flake-modules/example-vm.nix +++ b/flake-modules/example-vm.nix @@ -1,19 +1,18 @@ { inputs, lib, ... }: -let - system = "x86_64-linux"; - overlays = builtins.attrValues inputs.self.overlays; - config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-unwrapped" ]; - pkgs = import inputs.nixpkgs { inherit system overlays config; }; -in { # Example vm configuration flake.nixosConfigurations.vm = lib.nixosSystem { - inherit pkgs; modules = [ inputs.self.nixosModules.default ../example-vm # import vm configuration - { nix.registry.nixpkgs.flake = inputs.nixpkgs; } # pin nixpkgs to the one used by the system + { + nixpkgs = { + overlays = builtins.attrValues inputs.self.overlays; + config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ "steam-unwrapped" ]; + }; + # pin nixpkgs to the one used by the system + nix.registry.nixpkgs.flake = inputs.nixpkgs; + } ]; }; - }