From 04abc724b9a996a44058cce0078fe72a56bf8bbd Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 15 Nov 2024 21:03:09 -0500 Subject: [PATCH 1/6] nix-darwin: respect user configs --- modules/nix-darwin.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nix-darwin.nix b/modules/nix-darwin.nix index 8ed83fb..8a251bb 100644 --- a/modules/nix-darwin.nix +++ b/modules/nix-darwin.nix @@ -14,6 +14,10 @@ in ]; config = { + # Push the user's nix.conf into /etc/nix/nix.custom.conf, + # leaving determinate-nixd to manage /etc/nix/nix.conf + environment.etc."nix/nix.conf".target = "nix/nix.custom.conf"; + # Make Nix use the Nix daemon nix.useDaemon = true; From 5b2bffa5588801c88c987ed1fcb90b00005c30da Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 21 Jan 2025 09:07:04 -0800 Subject: [PATCH 2/6] nixos: respect user configs --- modules/nixos.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/nixos.nix b/modules/nixos.nix index 657945d..44d7294 100644 --- a/modules/nixos.nix +++ b/modules/nixos.nix @@ -15,6 +15,10 @@ in ]; config = { + # Push the user's nix.conf into /etc/nix/nix.custom.conf, + # leaving determinate-nixd to manage /etc/nix/nix.conf + environment.etc."nix/nix.conf".target = "nix/nix.custom.conf"; + environment.systemPackages = [ inputs.self.packages.${pkgs.stdenv.system}.default ]; From 8bf8c03d064e7124a28c9ecd60f356ec2d2f84b5 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 21 Jan 2025 09:10:00 -0800 Subject: [PATCH 3/6] tests/flake: remove home-manager input --- tests/flake.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/flake.nix b/tests/flake.nix index 2c77cdb..cca2326 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -6,13 +6,9 @@ url = "github:LnL7/nix-darwin/nix-darwin-24.11"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager = { - url = "github:nix-community/home-manager/release-24.05"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; - outputs = { nixpkgs, determinate, home-manager, nix-darwin, ... }: { + outputs = { nixpkgs, determinate, nix-darwin, ... }: { checks.x86_64-linux.nixos = (nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ From c795f35c8ae77861d02c2076af5d64a099d9a44a Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 21 Jan 2025 09:41:58 -0800 Subject: [PATCH 4/6] tests/flake: refactor, test `nix.custom.conf` * Make check creation more modular * Add check to test `nix.custom.conf` behavior * Move `checks` to `packages` (so we can build them and do additional checks in GHA) * Reformat according to nixfmt-rfc-style --- .github/workflows/ci.yml | 4 ++ tests/flake.nix | 96 ++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c0bcec..e4c1f2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,10 @@ jobs: rm -f flake.lock nix flake lock nix flake check + + # ensure relocating nix.conf to nix.custom.conf worked + nix build .#custom-conf --out-link /tmp/custom-conf + grep --quiet nix-community /tmp/custom-conf/etc/nix/nix.custom.conf - run: | set -eux diff --git a/tests/flake.nix b/tests/flake.nix index cca2326..01faaa5 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -8,31 +8,79 @@ }; }; - outputs = { nixpkgs, determinate, nix-darwin, ... }: { - checks.x86_64-linux.nixos = (nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - determinate.nixosModules.default + outputs = + { + nixpkgs, + determinate, + nix-darwin, + ... + }: + let + mkNixOS = { - fileSystems."/" = { - device = "/dev/bogus"; - fsType = "ext4"; - }; - boot.loader.grub.devices = [ "/dev/bogus" ]; - system.stateVersion = "24.11"; - } - ]; - }).config.system.build.toplevel; + modules ? [ ], + }: + (nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + determinate.nixosModules.default + { + fileSystems."/" = { + device = "/dev/bogus"; + fsType = "ext4"; + }; + boot.loader.grub.devices = [ "/dev/bogus" ]; + system.stateVersion = "24.11"; + } + ] ++ modules; + }).config.system.build.toplevel; - checks.aarch64-darwin.nix-darwin = (nix-darwin.lib.darwinSystem { - system = "aarch64-darwin"; - - modules = [ - determinate.darwinModules.default + mkNixDarwin = { - system.stateVersion = 5; - } - ]; - }).system; - }; + modules ? [ ], + }: + (nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + + modules = [ + determinate.darwinModules.default + { + system.stateVersion = 5; + } + ] ++ modules; + }).system; + in + { + packages.x86_64-linux = { + default = mkNixOS { }; + + custom-conf = mkNixOS { + modules = [ + { + nix.settings = { + substituters = [ "https://nix-community.cachix.org" ]; + trusted-substituters = [ "https://nix-community.cachix.org" ]; + trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; + }; + } + ]; + }; + }; + + packages.aarch64-darwin = { + default = mkNixDarwin { }; + + custom-conf = mkNixDarwin { + modules = [ + { + nix.settings = { + substituters = [ "https://nix-community.cachix.org" ]; + trusted-substituters = [ "https://nix-community.cachix.org" ]; + trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; + }; + } + ]; + }; + }; + }; } From 527afa924d48d6eaa3cb50538412c552ea31845f Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 23 Jan 2025 08:20:03 -0800 Subject: [PATCH 5/6] Revert "nix-darwin: respect user configs" This reverts commit 04abc724b9a996a44058cce0078fe72a56bf8bbd. --- modules/nix-darwin.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/nix-darwin.nix b/modules/nix-darwin.nix index 8a251bb..8ed83fb 100644 --- a/modules/nix-darwin.nix +++ b/modules/nix-darwin.nix @@ -14,10 +14,6 @@ in ]; config = { - # Push the user's nix.conf into /etc/nix/nix.custom.conf, - # leaving determinate-nixd to manage /etc/nix/nix.conf - environment.etc."nix/nix.conf".target = "nix/nix.custom.conf"; - # Make Nix use the Nix daemon nix.useDaemon = true; From f9d4f5a4cb69391d8c80f2a8e81ff20c65f28dfb Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 23 Jan 2025 08:22:48 -0800 Subject: [PATCH 6/6] Don't test nix.custom.conf relocation on darwin for now --- .github/workflows/ci.yml | 3 +++ tests/flake.nix | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4c1f2a..e4184f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,9 +47,12 @@ jobs: nix flake lock nix flake check + # don't check custom conf relocation on darwin while we work with nix-darwin to make this a good experience + if [ "$(nix eval --raw --impure --expr 'builtins.currentSystem')" = "x86_64-linux" ]; then # ensure relocating nix.conf to nix.custom.conf worked nix build .#custom-conf --out-link /tmp/custom-conf grep --quiet nix-community /tmp/custom-conf/etc/nix/nix.custom.conf + fi - run: | set -eux diff --git a/tests/flake.nix b/tests/flake.nix index 01faaa5..2332642 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -70,17 +70,17 @@ packages.aarch64-darwin = { default = mkNixDarwin { }; - custom-conf = mkNixDarwin { - modules = [ - { - nix.settings = { - substituters = [ "https://nix-community.cachix.org" ]; - trusted-substituters = [ "https://nix-community.cachix.org" ]; - trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; - }; - } - ]; - }; + # custom-conf = mkNixDarwin { + # modules = [ + # { + # nix.settings = { + # substituters = [ "https://nix-community.cachix.org" ]; + # trusted-substituters = [ "https://nix-community.cachix.org" ]; + # trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; + # }; + # } + # ]; + # }; }; }; }