diff --git a/home/emacs.nix b/home/emacs.nix index c9765eb..f0ec1e6 100644 --- a/home/emacs.nix +++ b/home/emacs.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, inputs, system, ... }: +{ pkgs, lib, flake, system, ... }: { # on macOS, emacs can be launched via: @@ -8,7 +8,7 @@ enable = true; package = let - emacsPgtkWithXwidgets = inputs.emacs-overlay.packages.${system}.emacsPgtk.override { + emacsPgtkWithXwidgets = flake.inputs.emacs-overlay.packages.${system}.emacsPgtk.override { withXwidgets = true; }; myEmacs = emacsPgtkWithXwidgets.overrideAttrs (oa: { diff --git a/home/neovim.nix b/home/neovim.nix index ea8679c..13eb12b 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, system, ... }: { imports = [ ./neovim/telescope.nix diff --git a/home/neovim/coc.nix b/home/neovim/coc.nix index cddf368..955ccba 100644 --- a/home/neovim/coc.nix +++ b/home/neovim/coc.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, system, ... }: { programs.neovim = { coc = { diff --git a/home/neovim/haskell.nix b/home/neovim/haskell.nix index 8d19557..671ecab 100644 --- a/home/neovim/haskell.nix +++ b/home/neovim/haskell.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, system, ... }: { programs.neovim = { coc.settings.languageserver.haskell = { diff --git a/home/neovim/rust.nix b/home/neovim/rust.nix index 919fc7d..73d14b2 100644 --- a/home/neovim/rust.nix +++ b/home/neovim/rust.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, flake, system, ... }: { programs.neovim = { coc.settings.languageserver.rust = { @@ -16,7 +16,7 @@ plugin = (pkgs.vimUtils.buildVimPlugin { name = "coc-rust-analyzer"; - src = inputs.coc-rust-analyzer; + src = flake.inputs.coc-rust-analyzer; }); type = "lua"; config = '' diff --git a/home/neovim/telescope.nix b/home/neovim/telescope.nix index b891bf2..4192108 100644 --- a/home/neovim/telescope.nix +++ b/home/neovim/telescope.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, system, ... }: { programs.neovim = { plugins = with pkgs.vimPlugins; [ diff --git a/home/neovim/which-key.nix b/home/neovim/which-key.nix index 83b16ec..c6c7f5e 100644 --- a/home/neovim/which-key.nix +++ b/home/neovim/which-key.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, system, ... }: { programs.neovim = { plugins = with pkgs.vimPlugins; [ diff --git a/home/neovim/zk.nix b/home/neovim/zk.nix index 40836a8..7b6b545 100644 --- a/home/neovim/zk.nix +++ b/home/neovim/zk.nix @@ -1,16 +1,16 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, flake, system, ... }: { programs.neovim = { extraPackages = [ pkgs.zk ]; - plugins = with pkgs.vimPlugins; [ + plugins = [ { plugin = (pkgs.vimUtils.buildVimPlugin { name = "zk-nvim"; - src = inputs.zk-nvim; + src = flake.inputs.zk-nvim; }); type = "lua"; config = '' diff --git a/home/terminal.nix b/home/terminal.nix index b66ea0f..6921563 100644 --- a/home/terminal.nix +++ b/home/terminal.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, system, ... }: +{ pkgs, flake, system, ... }: { # Key packages required on nixos and macos home.packages = with pkgs; [ @@ -7,7 +7,7 @@ ripgrep htop - inputs.comma.packages.${system}.default + flake.inputs.comma.packages.${system}.default ]; programs = { diff --git a/home/vscode-server.nix b/home/vscode-server.nix index e101c95..b259bc3 100644 --- a/home/vscode-server.nix +++ b/home/vscode-server.nix @@ -1,7 +1,7 @@ -{ pkgs, inputs, ... }: +{ pkgs, flake, ... }: { imports = [ - "${inputs.nixos-vscode-server}/modules/vscode-server/home.nix" + "${flake.inputs.nixos-vscode-server}/modules/vscode-server/home.nix" ]; services.vscode-server.enable = true; diff --git a/lib.nix b/lib.nix index 5b11545..48099db 100644 --- a/lib.nix +++ b/lib.nix @@ -1,5 +1,19 @@ # Support code for this repo. This module could be made its own external repo. { self, inputs, config, ... }: +let + specialArgsFor = rec { + common = { + flake = { inherit inputs config; }; + }; + x86_64-linux = common // { + system = "x86_64-linux"; + }; + aarch64-darwin = common // { + system = "aarch64-darwin"; + rosettaPkgs = import inputs.nixpkgs { system = "x86_64-darwin"; }; + }; + }; +in { flake = { # Linux home-manager module @@ -9,11 +23,7 @@ ({ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs; - system = "x86_64-linux"; - flake = { inherit config; }; - }; + home-manager.extraSpecialArgs = specialArgsFor.x86_64-linux; }) ]; }; @@ -24,11 +34,7 @@ ({ home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs; - system = "aarch64-darwin"; - flake = { inherit config; }; - }; + home-manager.extraSpecialArgs = specialArgsFor.aarch64-darwin; }) ]; }; @@ -36,20 +42,13 @@ mkLinuxSystem = mod: inputs.nixpkgs.lib.nixosSystem rec { system = "x86_64-linux"; # Arguments to pass to all modules. - specialArgs = { - inherit system inputs; - flake = { inherit config; }; - }; + specialArgs = specialArgsFor.${system}; modules = [ mod ]; }; mkMacosSystem = mod: inputs.darwin.lib.darwinSystem rec { system = "aarch64-darwin"; - specialArgs = { - inherit inputs system; - flake = { inherit config; }; - rosettaPkgs = import inputs.nixpkgs { system = "x86_64-darwin"; }; - }; + specialArgs = specialArgsFor.${system}; modules = [ mod ]; }; }; diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index 96bd955..31e7a94 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -1,4 +1,4 @@ -{ self, inputs, config, ... }: +{ self, config, ... }: { # Configuration common to all macOS systems flake = { diff --git a/nixos/cache-server.nix b/nixos/cache-server.nix index 7e57dfd..f1c7483 100644 --- a/nixos/cache-server.nix +++ b/nixos/cache-server.nix @@ -1,9 +1,9 @@ { keyName, domain }: -{ pkgs, lib, config, inputs, ... }: +{ pkgs, lib, config, flake, ... }: { imports = [ - inputs.nix-serve-ng.nixosModules.default + flake.inputs.nix-serve-ng.nixosModules.default ]; # Cache server diff --git a/nixos/desktopish/vscode.nix b/nixos/desktopish/vscode.nix index b8b023f..da3e0c9 100644 --- a/nixos/desktopish/vscode.nix +++ b/nixos/desktopish/vscode.nix @@ -1,6 +1,6 @@ -{ pkgs, inputs, ... }: { +{ pkgs, flake, ... }: { imports = [ - inputs.nixos-vscode-server.nixosModules.system + flake.inputs.nixos-vscode-server.nixosModules.system ]; services.auto-fix-vscode-server.enable = true; diff --git a/nixos/ema/emanote.nix b/nixos/ema/emanote.nix index 63d4711..56cc6b6 100644 --- a/nixos/ema/emanote.nix +++ b/nixos/ema/emanote.nix @@ -1,6 +1,6 @@ -{ pkgs, inputs, system, flake, ... }: +{ pkgs, system, flake, ... }: let - emanote = inputs.emanote.outputs.defaultPackage.${system}; + emanote = flake.inputs.emanote.outputs.defaultPackage.${system}; in { # Global service, rather than user service, as the latter doesn't work in NixOS-WSL diff --git a/nixos/hercules.nix b/nixos/hercules.nix index 8a8b69e..c58c8d5 100644 --- a/nixos/hercules.nix +++ b/nixos/hercules.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, inputs, system, ... }: +{ pkgs, lib, flake, system, ... }: { # TODO: use agenix to manage @@ -7,7 +7,7 @@ services.hercules-ci-agent = { enable = true; # nixpkgs may not always have the latest HCI. - package = inputs.hci.packages.${system}.hercules-ci-agent; + package = flake.inputs.hci.packages.${system}.hercules-ci-agent; }; # Regularly optimize nix store if using CI, because CI use can produce *lots* diff --git a/nixos/self-ide.nix b/nixos/self-ide.nix index 4f9414e..5d6f75c 100644 --- a/nixos/self-ide.nix +++ b/nixos/self-ide.nix @@ -1,4 +1,4 @@ -{ pkgs, inputs, flake, ... }: { +{ pkgs, flake, ... }: { # For no-prompt Ctrl+Shift+B in VSCode security.sudo.extraRules = [ { diff --git a/systems/darwin.nix b/systems/darwin.nix index a455862..8546719 100644 --- a/systems/darwin.nix +++ b/systems/darwin.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, inputs, system, flake, rosettaPkgs, ... }: +{ config, pkgs, lib, system, flake, rosettaPkgs, ... }: { environment.systemPackages = with pkgs; [ @@ -11,8 +11,8 @@ gh nixpkgs-fmt emanote - inputs.hci.packages.${system}.hercules-ci-cli - inputs.nixpkgs-match.packages.${system}.default + flake.inputs.hci.packages.${system}.hercules-ci-cli + flake.inputs.nixpkgs-match.packages.${system}.default # We must install Agda globally so that Doom-Emacs' agda config can # recognize it. It doesn't matter that our projects use Nix/direnv. @@ -44,8 +44,8 @@ ]; nix = { - nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc - registry.nixpkgs.flake = inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs + nixPath = [ "nixpkgs=${flake.inputs.nixpkgs}" ]; # Enables use of `nix-shell -p ...` etc + registry.nixpkgs.flake = flake.inputs.nixpkgs; # Make `nix shell` etc use pinned nixpkgs extraOptions = '' extra-platforms = aarch64-darwin x86_64-darwin experimental-features = nix-command flakes repl-flake diff --git a/systems/hetzner/ax101.nix b/systems/hetzner/ax101.nix index d03978e..5e73b26 100644 --- a/systems/hetzner/ax101.nix +++ b/systems/hetzner/ax101.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, inputs, modulesPath, flake, ... }: +{ config, pkgs, lib, modulesPath, flake, ... }: { imports =