From 67cf3adb8e61ee4a0086f0de26719defd4a625e6 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Mon, 7 Oct 2024 20:38:59 -0500 Subject: [PATCH 1/2] Properly export all packages for CI builds We now properly handle deeply merging attributes, allowing us to export both the home-manager configuration and other packages. This additionally modifies `./pkgs/default.nix` to take a single argument, `pkgs`. --- flake.lock | 18 ++++++------- flake.nix | 69 ++++++++++++++++++++---------------------------- pkgs/default.nix | 9 +++---- 3 files changed, 42 insertions(+), 54 deletions(-) diff --git a/flake.lock b/flake.lock index 23f39dc..1d756ae 100644 --- a/flake.lock +++ b/flake.lock @@ -55,11 +55,11 @@ ] }, "locked": { - "lastModified": 1727383923, - "narHash": "sha256-4/vacp3CwdGoPf8U4e/N8OsGYtO09WTcQK5FqYfJbKs=", + "lastModified": 1728337164, + "narHash": "sha256-VdRTjJFyq4Q9U7Z/UoC2Q5jK8vSo6E86lHc2OanXtvc=", "owner": "nix-community", "repo": "home-manager", - "rev": "ffe2d07e771580a005e675108212597e5b367d2d", + "rev": "038630363e7de57c36c417fd2f5d7c14773403e4", "type": "github" }, "original": { @@ -90,11 +90,11 @@ ] }, "locked": { - "lastModified": 1727707210, - "narHash": "sha256-8XZp5XO2FC6INZEZ2WlwErtvFVpl45ACn8CJ2hfTA0Y=", + "lastModified": 1727999297, + "narHash": "sha256-LTJuQPCsSItZ/8TieFeP30iY+uaLoD0mT0tAj1gLeyQ=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "f61d5f2051a387a15817007220e9fb3bbead57b3", + "rev": "8c8388ade72e58efdeae71b4cbb79e872c23a56b", "type": "github" }, "original": { @@ -105,11 +105,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727634051, - "narHash": "sha256-S5kVU7U82LfpEukbn/ihcyNt2+EvG7Z5unsKW9H/yFA=", + "lastModified": 1728018373, + "narHash": "sha256-NOiTvBbRLIOe5F6RbHaAh6++BNjsb149fGZd1T4+KBg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "06cf0e1da4208d3766d898b7fdab6513366d45b9", + "rev": "bc947f541ae55e999ffdb4013441347d83b00feb", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 10392b2..356d84d 100644 --- a/flake.nix +++ b/flake.nix @@ -42,21 +42,24 @@ }; in { - # There's a few things going on here that are all merged in the end. - # We start with a generalized package overlay, providing several packages + # First, we provide a generalized package overlay, providing several packages # for e.g. nix-darwin, NixOS, and home-manager usage. - overlays.default = (import ./pkgs/default.nix); + # ./pkgs/default.nix's singular argument, `pkgs`, is provided by our `final`. + overlays.default = (final: prev: import ./pkgs/default.nix { + pkgs = final; + }); - # Secondly, we create system-specific home-manager configurations. + # Next, we provide Linux-specific home-manager configurations, + # and expose our default packages to the world. packages = - ########################## - # Linux-specific options # - ########################## - linuxSystems - (system: { + let + ########################## + # Linux-specific options # + ########################## + linuxConfiguration = linuxSystems (system: { homeConfigurations = { - # First, we currently assume that Linux devices - # only require dotfiles and utilize the username `spotlight`. + # We currently assume that Linux devices only require + # dotfiles and utilize the username `spotlight`. # # For now, this is effectively true, sans a few specific configurations :) spotlight = homeManager { @@ -73,37 +76,23 @@ }; }; }; - }) + }); - // + # For all platforms, export our packages for CI to build. + exportedPackages = allSystems (system: import ./pkgs/default.nix { + pkgs = nixpkgs.legacyPackages.${system}; + }); - ########################### - # Darwin-specific options # - ########################### - darwinSystems (system: { - # We use the username `spot` under Darwin. - # We also assume that desktop applications should be made available, alongside GPG. - homeConfigurations.spot = homeManager { - system = system; - specialArgs = { - desktop = true; - gpg = true; - }; - }; - }); - - # // - # - # #################### - # # Generic packages # - # #################### - # # We'll export some of our overlay's packages for CI to build. - # allSystems (system: { - # packages = { - # swiftformat = import ./pkgs/swiftformat.nix; - # monaco-powerline = import ./monaco-powerline/default.nix; - # }; - # }); + # We must use recursiveUpdate in order to go deeper beyond one level. + # For example, `linuxConfiguration` provides `packages.x86_64-linux.homeConfiguration` + # and `exportedPackages` provides `packages.x86_64-linux.`. + # + # With the normal `//` syntax, `packages.x86_64-linux` is not recursively merged, + # and either packages or the home-manager configuration end up being replaced. + # This is not ideal :( + recursiveUpdate = nixpkgs.lib.recursiveUpdate; + in + recursiveUpdate linuxConfiguration exportedPackages; # We provide a NixOS module for easy usage within other system flakes. # (Again, we assume a default name of `spotlight` under Linux.) diff --git a/pkgs/default.nix b/pkgs/default.nix index 83be1a5..548a048 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,6 +1,5 @@ -self: super: -{ - ipsw = super.callPackage ./ipsw.nix { }; - monaco-powerline = super.callPackage ./monaco-powerline/default.nix { }; - swiftformat = super.callPackage ./swiftformat.nix { }; +{ pkgs, ... }: { + ipsw = pkgs.callPackage ./ipsw.nix { }; + monaco-powerline = pkgs.callPackage ./monaco-powerline/default.nix { }; + swiftformat = pkgs.callPackage ./swiftformat.nix { }; } From 378572fe5bb8c8f2d15e8c5b5254ffbaf08578e8 Mon Sep 17 00:00:00 2001 From: Spotlight Date: Mon, 7 Oct 2024 20:57:29 -0500 Subject: [PATCH 2/2] home-manager: Properly use flake-provided overly Oops :) --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 356d84d..372db3b 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,7 @@ modules = [ ./home/home.nix ]; - pkgs = nixpkgs.legacyPackages.${system}.extend (import ./pkgs/default.nix); + pkgs = nixpkgs.legacyPackages.${system}.extend (self.overlays.default); extraSpecialArgs = specialArgs; }; in