From e3b1539b41066bead632adf50be55fd05d2cf823 Mon Sep 17 00:00:00 2001 From: reo101 Date: Sat, 20 Jul 2024 14:30:25 +0300 Subject: [PATCH] refactor(flake)!: deduplicate code in `configurations` flake module Pass around `perSystem`'s `pkgs` instances to the system configurations Some more refactoring in `configurations`' `mkHost` functions Also start using `home-manager`'s `useGlobalPkgs` option Also use `mkShellNoCC` for default `devShell` Also `nix flake update` --- flake.lock | 54 +++--- flake.nix | 6 +- .../x86_64-linux/__template__/home.nix | 26 --- .../aarch64-darwin/limonka/configuration.nix | 25 +-- .../limonka/home/pavelatanasov.nix | 53 ++++-- .../x86_64-darwin/apavel-a01/home/apavel.nix | 8 - .../limontozu/home/pavelatanasov.nix | 8 - .../aarch64-linux/cheetah/home.nix | 9 - .../x86_64-linux/homix/configuration.nix | 6 - .../nixos/x86_64-linux/homix/home/reo101.nix | 10 - .../x86_64-linux/jeeves/configuration.nix | 9 - .../nixos/x86_64-linux/jeeves/home/jeeves.nix | 6 - modules/home-manager/nix-general/default.nix | 14 +- nix/configurations.nix | 171 ++++++++---------- nix/pkgs.nix | 14 +- overlays/default.nix | 2 +- shells/default.nix | 3 +- shells/default/default.nix | 3 +- templates/default.nix | 2 +- 19 files changed, 183 insertions(+), 246 deletions(-) diff --git a/flake.lock b/flake.lock index 19bf6b5..6dedddf 100644 --- a/flake.lock +++ b/flake.lock @@ -37,11 +37,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1721071152, - "narHash": "sha256-GoshD2O4dDNuGPPK4AiVCkM38j9/8OImYudY0zjFDcc=", + "lastModified": 1721402988, + "narHash": "sha256-O5j5y5gpssVF5FNsSF7joTyrlW//LpwyLk6yBWgQ0VE=", "owner": "oddlama", "repo": "agenix-rekey", - "rev": "d63898728266e3a30f5367a0efbbfaedf9cf8041", + "rev": "3f1c787e2092d9c13142ae7572cc1c52b68f1c4c", "type": "github" }, "original": { @@ -175,11 +175,11 @@ ] }, "locked": { - "lastModified": 1721266288, - "narHash": "sha256-MsyTzXu9CJVcBr44ct8ILKF/Ro7VlF+tVZTylzAoXSs=", + "lastModified": 1721417620, + "narHash": "sha256-6q9b1h8fI3hXg2DG6/vrKWCeG8c5Wj2Kvv22RCgedzg=", "owner": "nix-community", "repo": "disko", - "rev": "e8e8d9a3a9c1d0e654ccda7834bf0288a9d15c47", + "rev": "bec6e3cde912b8acb915fecdc509eda7c973fb42", "type": "github" }, "original": { @@ -674,11 +674,11 @@ }, "hardware": { "locked": { - "lastModified": 1721331912, - "narHash": "sha256-h2yaU+QEU4pHxMySHPIsRV2T/pihDHnrXBca8BY6xgc=", + "lastModified": 1721413321, + "narHash": "sha256-0GdiQScDceUrVGbxYpV819LHesK3szHOhJ09e6sgES4=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "bb90787ea034c8b9035dfcfc9b4dc23898d414be", + "rev": "ab165a8a6cd12781d76fe9cbccb9e975d0fb634f", "type": "github" }, "original": { @@ -823,11 +823,11 @@ ] }, "locked": { - "lastModified": 1721281012, - "narHash": "sha256-km+EYinh23cAztAFDi2dX/Dqx9NN9jjmyFAII1CZB4Y=", + "lastModified": 1721368131, + "narHash": "sha256-dvDYa+Z2qZHTibmeUbKKIpR2jONO4UPbyHiDgYhgoMQ=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "bc1d14af6c0834c68b09fdfd588b4e82bd8177d1", + "rev": "d9fcc47baa026c7df9a9789d5e825b4f13a9239a", "type": "github" }, "original": { @@ -839,11 +839,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1721260040, - "narHash": "sha256-Aj1WC8RCOx000R97YPzocO3QGTaj0YVhGF1fDxWwqWo=", + "lastModified": 1721316387, + "narHash": "sha256-qPgppLqmnd0OnHLMo4cGPZSUyLbcw9nThWO4sJC8bWI=", "owner": "neovim", "repo": "neovim", - "rev": "185b22720de9156393ddc22c2c59dc3eb46b8d97", + "rev": "f61efe3fe77c9a517dccb9fd5ff7f16c0660ced4", "type": "github" }, "original": { @@ -1119,11 +1119,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1721138476, - "narHash": "sha256-+W5eZOhhemLQxelojLxETfbFbc19NWawsXBlapYpqIA=", + "lastModified": 1721379653, + "narHash": "sha256-8MUgifkJ7lkZs3u99UDZMB4kbOxvMEXQZ31FO3SopZ0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ad0b5eed1b6031efaed382844806550c3dcb4206", + "rev": "1d9c2c9b3e71b9ee663d11c5d298727dace8d374", "type": "github" }, "original": { @@ -1221,11 +1221,11 @@ }, "nur": { "locked": { - "lastModified": 1721335575, - "narHash": "sha256-dry8Y8MwACIdIBVFDOFQGpKd8PmEIPv9Ej0UdrdOlG8=", + "lastModified": 1721472350, + "narHash": "sha256-XFGmZB6GhnYsTOFouj60lc40OkZxpdk6mL2nTT0fIkU=", "owner": "nix-community", "repo": "NUR", - "rev": "6e46867fdecc920a1de55dc1e553a16f54e2d2ee", + "rev": "b4365ef44d92f9f6bd6ad3e54117d1719ebd2c57", "type": "github" }, "original": { @@ -1651,11 +1651,11 @@ ] }, "locked": { - "lastModified": 1721304636, - "narHash": "sha256-vpincauiWXBtlQLzGQNjAGlOjfOuh+nb30AUAsnMhWs=", + "lastModified": 1721390978, + "narHash": "sha256-he5AUpgwVAT/VXtkUOiMsz5cYblXw2qAGs1wADW9ji8=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "a88326d1947156a6ad22b00d44fb3f1bf0a98673", + "rev": "c7615d701b2a5355a3f3013918b6b945c394e791", "type": "github" }, "original": { @@ -1677,11 +1677,11 @@ ] }, "locked": { - "lastModified": 1721153775, - "narHash": "sha256-kReih1LP5I9J0P+ByAOKNv/d4re0P/bH2AD6InGjN1U=", + "lastModified": 1721428418, + "narHash": "sha256-4CLofMcvvunlfZ0irCjEWCzetMMwuBUaski2qwNtsjk=", "owner": "zigtools", "repo": "zls", - "rev": "41dae221fab979b3764e9191d8126e09625b0bb2", + "rev": "b9e17146ba64d683fed0cb07156ec6052207f4d4", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a20e744..e8768a9 100644 --- a/flake.nix +++ b/flake.nix @@ -164,7 +164,7 @@ apps = import ./apps { inherit pkgs; }; # Dev Shells (`nix develop`) - devShells = import ./shells { inherit pkgs inputs outputs; }; + devShells = import ./shells { inherit pkgs inputs; }; # Formatter (`nix fmt`) formatter = pkgs.nixpkgs-fmt; @@ -175,12 +175,12 @@ # Templates templates = import ./templates { - inherit inputs outputs; + inherit inputs; }; # Overlays overlays = import ./overlays { - inherit inputs outputs; + inherit inputs; }; }; }); diff --git a/machines/home-manager/x86_64-linux/__template__/home.nix b/machines/home-manager/x86_64-linux/__template__/home.nix index 4df5ed4..686c2e5 100644 --- a/machines/home-manager/x86_64-linux/__template__/home.nix +++ b/machines/home-manager/x86_64-linux/__template__/home.nix @@ -14,32 +14,6 @@ ./nvim.nix ]; - nixpkgs = { - # You can add overlays here - overlays = [ - # If you want to use overlays your own flake exports (from overlays dir): - # outputs.overlays.modifications - # outputs.overlays.additions - - # Or overlays exported from other flakes: - # neovim-nightly-overlay.overlays.default - - # Or define it inline, for example: - # (final: prev: { - # hi = final.hello.overrideAttrs (oldAttrs: { - # patches = [ ./change-hello-to-hi.patch ]; - # }); - # }) - ]; - # Configure your nixpkgs instance - config = { - # Disable if you don't want unfree packages - allowUnfree = true; - # Workaround for https://github.com/nix-community/home-manager/issues/2942 - allowUnfreePredicate = (_: true); - }; - }; - # TODO: Set your username home = { username = "your-username"; diff --git a/machines/nix-darwin/aarch64-darwin/limonka/configuration.nix b/machines/nix-darwin/aarch64-darwin/limonka/configuration.nix index c14656e..d374f96 100644 --- a/machines/nix-darwin/aarch64-darwin/limonka/configuration.nix +++ b/machines/nix-darwin/aarch64-darwin/limonka/configuration.nix @@ -8,10 +8,21 @@ # Auto upgrade nix package and the daemon service. services.nix-daemon.enable = true; - nix = { + nix = let + flakeInputs = lib.filterAttrs (lib.const (lib.isType "flake")) inputs; + in { # Ensure we can work with flakes + # NOTE: run `sudo -i nix-env --uninstall nix` to uninstall the global `nix` package = pkgs.nixVersions.monitored.latest; + # This will add each flake input as a registry + # To make nix3 commands consistent with your flake + registry = lib.mapAttrs (_: value: { flake = value; }) flakeInputs; + + # This will additionally add your inputs to the system's legacy channels + # Making legacy nix commands consistent as well, awesome! + nixPath = lib.mapAttrsToList (key: value: "${key}=flake:${key}") flakeInputs; + # extraOptions = '' # # Enable flakes and new 'nix' command # experimental-features = nix-command flakes @@ -24,15 +35,6 @@ # keep-derivations = true # ''; - # registry.nixpkgs.flake = inputs.nixpkgs; - # registry = - # lib.mapAttrs' - # (name: value: - # { - # name = name; - # value = { flake = value; }; - # }) - # inputs; settings = { # Enable flakes and new 'nix' command @@ -89,8 +91,7 @@ programs.zsh.enable = true; # default shell on catalina # Fonts - fonts.fontDir.enable = true; - fonts.fonts = with pkgs; [ + fonts.packages = with pkgs; [ (nerdfonts.override { fonts = [ "FiraCode" ]; }) ]; diff --git a/machines/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix b/machines/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix index 698c5f2..681ff5f 100644 --- a/machines/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix +++ b/machines/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix @@ -7,14 +7,6 @@ stateVersion = "23.05"; }; - # Add custom overlays - nixpkgs = { - overlays = builtins.attrValues outputs.overlays ++ [ - inputs.neovim-nightly-overlay.overlays.default - inputs.zig-overlay.overlays.default - ]; - }; - # Set env vars home.sessionVariables = { EDITOR = "nvim"; @@ -40,18 +32,33 @@ # Neovim neovim + # (neovim.overrideAttrs (oldAttrs: { + # lua = luajitcoroutineclone; + # })) + (pkgs.writeShellScriptBin "lua" "exec -a $0 ${luajitPackages.nlua}/bin/nlua $@") + # luajitPackages.nlua fennel - fennel-language-server + # fennel-language-server + fennel-ls git gh + # (gnumake.override { guileSupport = true; }) + gnumake + + # # Emacs + # (emacs-unstable.override { + # withGTK3 = true; + # : + # }) + # Dhall - dhall + # dhall # dhall-lsp-server # Circom - circom - circom-lsp + # circom + # circom-lsp # Nix nil @@ -61,6 +68,9 @@ # Mail # himalaya + # Java + graalvm-ce + # SSH and GPG openssh gnupg @@ -99,8 +109,27 @@ wezterm = { enable = true; }; + spotify = { + enable = false; + }; }; + # programs.git = { + # enable = true; + # userName = "reo101"; + # # userEmail = "pavel.atanasov@limechain.tech"; + # userEmail = "pavel.atanasov2001@gmail.com"; + # signing = { + # signByDefault = true; + # key = "675AA7EF13964ACB"; + # }; + # # init.defaultBranch = "master"; + # lfs = { + # enable = true; + # }; + # }; + + home.file.".gnupg/gpg-agent.conf" = { text = '' allow-preset-passphrase diff --git a/machines/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix b/machines/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix index 0152ae8..0045935 100644 --- a/machines/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix +++ b/machines/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix @@ -23,14 +23,6 @@ inputs.zls-overlay.packages.x86_64-darwin.default ]; - nixpkgs = { - overlays = [ - inputs.zig-overlay.overlays.default - ]; - - config.allowUnfree = true; - }; - programs.git = { enable = true; userName = "apavel"; diff --git a/machines/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix b/machines/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix index c422441..3974b0e 100644 --- a/machines/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix +++ b/machines/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix @@ -7,14 +7,6 @@ stateVersion = "23.05"; }; - # Add custom overlays - nixpkgs = { - overlays = [ - inputs.neovim-nightly-overlay.overlays.default - inputs.zig-overlay.overlays.default - ]; - }; - # Set env vars home.sessionVariables = { EDITOR = "nvim"; diff --git a/machines/nix-on-droid/aarch64-linux/cheetah/home.nix b/machines/nix-on-droid/aarch64-linux/cheetah/home.nix index 4ef8b35..7b4135b 100644 --- a/machines/nix-on-droid/aarch64-linux/cheetah/home.nix +++ b/machines/nix-on-droid/aarch64-linux/cheetah/home.nix @@ -10,15 +10,6 @@ stateVersion = "23.05"; }; - # Add custom overlays - nixpkgs = { - overlays = [ - inputs.neovim-nightly-overlay.overlays.default - inputs.zig-overlay.overlays.default - # inputs.zls-overlay.??? - ]; - }; - # Let Home Manager install and manage itself. programs.home-manager.enable = true; diff --git a/machines/nixos/x86_64-linux/homix/configuration.nix b/machines/nixos/x86_64-linux/homix/configuration.nix index 90b4339..a127563 100644 --- a/machines/nixos/x86_64-linux/homix/configuration.nix +++ b/machines/nixos/x86_64-linux/homix/configuration.nix @@ -94,12 +94,6 @@ }; }; - nixpkgs = { - config = { - allowUnfree = true; - }; - }; - ### Fonts fonts.fontconfig.enable = true; diff --git a/machines/nixos/x86_64-linux/homix/home/reo101.nix b/machines/nixos/x86_64-linux/homix/home/reo101.nix index 081008a..56dbecc 100644 --- a/machines/nixos/x86_64-linux/homix/home/reo101.nix +++ b/machines/nixos/x86_64-linux/homix/home/reo101.nix @@ -5,16 +5,6 @@ inputs.wired.homeManagerModules.default ]; - nixpkgs = { - overlays = builtins.attrValues outputs.overlays ++ [ - inputs.neovim-nightly-overlay.overlays.default - inputs.zig-overlay.overlays.default - inputs.wired.overlays.default - ]; - - config.allowUnfree = true; - }; - home = { username = "reo101"; homeDirectory = "/home/reo101"; diff --git a/machines/nixos/x86_64-linux/jeeves/configuration.nix b/machines/nixos/x86_64-linux/jeeves/configuration.nix index e8958c9..f553b0f 100644 --- a/machines/nixos/x86_64-linux/jeeves/configuration.nix +++ b/machines/nixos/x86_64-linux/jeeves/configuration.nix @@ -22,15 +22,6 @@ # localStorageDir = "${inputs.self}/secrets/rekeyed/${config.networking.hostName}"; }; - nixpkgs = { - hostPlatform = "x86_64-linux"; - config = { - allowUnfree = true; - }; - overlays = [ - ]; - }; - networking.hostName = "jeeves"; boot = { diff --git a/machines/nixos/x86_64-linux/jeeves/home/jeeves.nix b/machines/nixos/x86_64-linux/jeeves/home/jeeves.nix index b91b395..f3b71bd 100644 --- a/machines/nixos/x86_64-linux/jeeves/home/jeeves.nix +++ b/machines/nixos/x86_64-linux/jeeves/home/jeeves.nix @@ -5,12 +5,6 @@ inputs.wired.homeManagerModules.default ]; - nixpkgs = { - overlays = builtins.attrValues outputs.overlays; - - config.allowUnfree = true; - }; - home = { username = "jeeves"; homeDirectory = "/home/jeeves"; diff --git a/modules/home-manager/nix-general/default.nix b/modules/home-manager/nix-general/default.nix index 26e3b8f..9829568 100644 --- a/modules/home-manager/nix-general/default.nix +++ b/modules/home-manager/nix-general/default.nix @@ -18,11 +18,13 @@ # inputs); # }; - # Use flake overlays by default - nixpkgs = { - overlays = lib.attrValues outputs.overlays; - - config.allowUnfree = true; - }; + # NOTE: now automatic, since we're doing `useGlobalPkgs = true` + # + # # Use flake overlays by default + # nixpkgs = { + # overlays = lib.attrValues outputs.overlays; + # + # config.allowUnfree = true; + # }; }; } diff --git a/nix/configurations.nix b/nix/configurations.nix index 4565b18..c0114ed 100644 --- a/nix/configurations.nix +++ b/nix/configurations.nix @@ -1,8 +1,6 @@ -{ lib, config, self, inputs, ... }: +{ lib, config, self, inputs, withSystem, ... }: let - inherit (inputs) - nixpkgs; # TODO: works? outputs = self; inherit (import ./utils.nix { inherit lib self; }) @@ -11,31 +9,45 @@ let hasDirectories; in let + homeManagerModule = { root, system, hostname, users ? null }: { + home-manager = { + # Use same `pkgs` instance as system (i.e. carry over overlays) + useGlobalPkgs = true; + # Do not keep packages in ${HOME} + useUserPackages = true; + # Default import all of our exported homeManagerModules + sharedModules = builtins.attrValues config.flake.homeManagerModules; + # Pass in `inputs`, `outputs` and maybe `meta` + extraSpecialArgs = { + inherit inputs outputs; + # TODO: meta? + inherit hostname; + }; + } // (if users == null then { + # nixOnDroid + config = (lib.path.append root "home.nix"); + } else { + # Not nixOnDroid + users = lib.attrsets.genAttrs + users + (user: import (lib.path.append root "home/${user}.nix")); + }); + }; + # Configuration helpers - mkNixosHost = root: system: hostname: users: lib.nixosSystem { + mkNixosHost = args @ { root, system, hostname, users }: lib.nixosSystem { inherit system; + pkgs = withSystem system ({ pkgs, ... }: pkgs); modules = [ + # Main configuration (lib.path.append root "configuration.nix") + # Home Manager inputs.home-manager.nixosModules.home-manager + (homeManagerModule args) + # nix-topology inputs.nix-topology.nixosModules.default - { - nixpkgs.overlays = builtins.attrValues self.overlays; - } - { - home-manager = { - useGlobalPkgs = false; - useUserPackages = true; - users = lib.attrsets.genAttrs - users - (user: import (lib.path.append root "home/${user}.nix")); - sharedModules = builtins.attrValues config.flake.homeManagerModules; - extraSpecialArgs = { - inherit inputs outputs; - inherit hostname; - }; - }; - } + # Sane default `networking.hostName` { networking.hostName = lib.mkDefault hostname; } @@ -46,71 +58,39 @@ let }; }; - mkNixOnDroidHost = root: system: hostname: inputs.nix-on-droid.lib.nixOnDroidConfiguration { - pkgs = import nixpkgs { - inherit system; - - overlays = builtins.attrValues self.overlays ++ [ - inputs.nix-on-droid.overlays.default - ]; - }; + mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration { + # NOTE: inferred by `pkgs.system` + # inherit system; + pkgs = withSystem system ({ pkgs, ... }: pkgs); modules = [ + # Main configuration (lib.path.append root "configuration.nix") - { - home-manager = { - config = (lib.path.append root "home.nix"); - backupFileExtension = "hm-bak"; - useGlobalPkgs = false; - useUserPackages = true; - sharedModules = builtins.attrValues config.flake.homeManagerModules ++ [ - { - nixpkgs.overlays = builtins.attrValues self.overlays; - } - ]; - extraSpecialArgs = { - inherit inputs outputs; - inherit hostname; - }; - }; - } + # Home Manager + (homeManagerModule args) ] ++ (builtins.attrValues config.flake.nixOnDroidModules); extraSpecialArgs = { inherit inputs outputs; - inherit hostname; - # rootPath = ./.; }; home-manager-path = inputs.home-manager.outPath; }; - mkNixDarwinHost = root: system: hostname: users: inputs.nix-darwin.lib.darwinSystem { + mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem { inherit system; + pkgs = withSystem system ({ pkgs, ... }: pkgs); modules = [ + # Main configuration (lib.path.append root "configuration.nix") - { - nixpkgs.hostPlatform = system; - } - { - nixpkgs.overlays = builtins.attrValues self.overlays; - } + # Home Manager inputs.home-manager.darwinModules.home-manager - { - home-manager = { - useGlobalPkgs = false; - useUserPackages = true; - users = lib.attrsets.genAttrs - users - (user: import (lib.path.append root "home/${user}.nix")); - sharedModules = builtins.attrValues config.flake.homeManagerModules; - extraSpecialArgs = { - inherit inputs outputs; - inherit hostname; - }; - }; - } + (homeManagerModule args) + # # Set `nixpkgs.hostPlatform` + # { + # nixpkgs.hostPlatform = system; + # } ] ++ (builtins.attrValues config.flake.nixDarwinModules); specialArgs = { @@ -118,14 +98,12 @@ let }; }; - mkHomeManagerHost = root: system: hostname: inputs.home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; + mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration { + inherit system; + pkgs = withSystem system ({ pkgs, ... }: pkgs); modules = [ (lib.path.append root "home.nix") - { - nixpkgs.overlays = builtins.attrValues self.overlays; - } ] ++ (builtins.attrValues config.flake.homeManagerModules); extraSpecialArgs = { @@ -154,7 +132,6 @@ let }) hosts) machines)); - in { flake = { @@ -172,13 +149,14 @@ in # config) ]) (system: host: configuration: - mkNixosHost - ../machines/nixos/${system}/${host} - system - host - (builtins.map + mkNixosHost { + root = ../machines/nixos/${system}/${host}; + inherit system; + hostname = host; + users = (builtins.map (lib.strings.removeSuffix ".nix") - (builtins.attrNames (configuration."home" or { })))) + (builtins.attrNames (configuration."home" or { }))); + }) config.flake.nixosMachines; nixOnDroidConfigurations = @@ -191,10 +169,11 @@ in configuration) ]) (system: host: configuration: - mkNixOnDroidHost - ../machines/nix-on-droid/${system}/${host} - system - host) + mkNixOnDroidHost { + root = ../machines/nix-on-droid/${system}/${host}; + inherit system; + hostname = host; + }) config.flake.nixOnDroidMachines; darwinConfigurations = @@ -210,13 +189,14 @@ in configuration) ]) (system: host: configuration: - mkNixDarwinHost - ../machines/nix-darwin/${system}/${host} - system - host - (builtins.map + mkNixDarwinHost { + root = ../machines/nix-darwin/${system}/${host}; + inherit system; + hostname = host; + users = (builtins.map (lib.strings.removeSuffix ".nix") - (builtins.attrNames (configuration."home" or { })))) + (builtins.attrNames (configuration."home" or { }))); + }) config.flake.nixDarwinMachines; homeConfigurations = @@ -229,10 +209,11 @@ in configuration) ]) (system: host: configuration: - mkHomeManagerHost - ../machines/home-manager/${system}/${host} - system - host) + mkHomeManagerHost { + root = ../machines/home-manager/${system}/${host}; + inherit system; + hostname = host; + }) config.flake.homeManagerMachines; }; } diff --git a/nix/pkgs.nix b/nix/pkgs.nix index 78c42e2..e7b2e9c 100644 --- a/nix/pkgs.nix +++ b/nix/pkgs.nix @@ -1,13 +1,21 @@ -{ lib, config, self, inputs, ... }: +{ inputs, self, lib, config, ... }: { - perSystem = { lib, pkgs, system, ... }: { + perSystem = { system, ... }: { _module.args.pkgs = import inputs.nixpkgs { inherit system; overlays = lib.attrValues self.overlays ++ [ + inputs.neovim-nightly-overlay.overlays.default + inputs.zig-overlay.overlays.default inputs.nix-topology.overlays.default + inputs.wired.overlays.default + # nix-on-droid overlay (needed for `proot`) + inputs.nix-on-droid.overlays.default ]; - config = { }; + config = { + # TODO: per machine? + allowUnfree = true; + }; }; }; } diff --git a/overlays/default.nix b/overlays/default.nix index 5a87267..17f79d7 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,5 @@ # This file defines overlays -{ inputs, outputs, ... }: +{ inputs, ... }: { # This one brings our custom packages from the 'pkgs' directory additions = final: _prev: import ../pkgs { diff --git a/shells/default.nix b/shells/default.nix index 4bf0ce8..20f89e7 100644 --- a/shells/default.nix +++ b/shells/default.nix @@ -1,8 +1,7 @@ # If pkgs is not defined, instanciate nixpkgs from locked commit { pkgs ? (import ../nixpkgs.nix) { } , inputs -, outputs , ... }: { - default = import ./default { inherit pkgs inputs outputs; }; + default = import ./default { inherit pkgs inputs; }; } diff --git a/shells/default/default.nix b/shells/default/default.nix index d964c37..462ea5d 100644 --- a/shells/default/default.nix +++ b/shells/default/default.nix @@ -1,9 +1,8 @@ # Shell for bootstrapping flake-enabled nix and other tooling { pkgs , inputs -, outputs , ... -}: pkgs.mkShell { +}: pkgs.mkShellNoCC { NIX_CONFIG = '' extra-experimental-features = nix-command flakes ''; diff --git a/templates/default.nix b/templates/default.nix index 8b69984..7ee0428 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -1,3 +1,3 @@ -{ inputs, outputs, ... }: +{ inputs, ... }: { }