Personal Nix setup

Clean up

Changed files
+76 -85
lib
machines
modules
+8 -11
flake.nix
···
apple-silicon = {
url = "github:tpwrules/nixos-apple-silicon";
-
inputs = {
-
nixpkgs.follows = "nixpkgs";
-
};
+
inputs.nixpkgs.follows = "nixpkgs";
};
lanzaboote = {
url = "github:nix-community/lanzaboote";
-
inputs = {
-
nixpkgs.follows = "nixpkgs";
-
};
+
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
···
};
};
-
outputs = { apple-silicon, ...} @ inputs: let
+
outputs = inputs: let
inherit (import ./lib/system.nix inputs) mkSystem;
-
eachSystem = inputs.nixpkgs.lib.genAttrs ["aarch64-darwin" "aarch64-linux" "x86_64-linux"];
+
eachSystem = inputs.nixpkgs.lib.genAttrs ["aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"];
+
eachDarwinSystem = inputs.nixpkgs.lib.genAttrs ["aarch64-darwin" "x86_64-darwin"];
overlays = [
inputs.nvim-plugins.overlays.default
(self: super: {
···
};
nixosConfigurations."ramune" = mkSystem {
-
overlays = overlays ++ [
-
apple-silicon.overlays.apple-silicon-overlay
-
];
+
inherit overlays;
system = "aarch64-linux";
hostname = "ramune";
};
packages = eachSystem (system: {
inherit (inputs.agenix.packages.${system}) agenix;
+
}) // eachDarwinSystem (system: {
+
inherit (inputs.darwin.packages.${system}) darwin-rebuild;
});
};
}
+3 -2
lib/system.nix
···
nixpkgs = {
inherit overlays;
config.allowUnfree = true;
+
hostPlatform = system;
};
networking.hostName = hostname;
···
];
};
-
specialArgs = inputs // {
-
inherit hostname user;
+
specialArgs = {
+
inherit hostname user inputs;
helpers = (import ./helpers.nix {
inherit lib system;
});
+3 -7
machines/cola/hardware.nix
···
-
{ config, lib, nixos-hardware, modulesPath, ... }:
+
{ config, lib, inputs, modulesPath, ... }:
{
-
imports = [
+
imports = with inputs; [
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-pc-ssd
nixos-hardware.nixosModules.common-pc
···
{ device = "/dev/disk/by-label/NIXSWAP"; }
];
-
# set host and allow unfree
-
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
-
nixpkgs.config.allowUnfree = true;
-
-
# enable Intel microcode update and firmware
+
# enable Intel microcode update and firmware
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.enableAllFirmware = true;
+1 -1
machines/pepper/configuration.nix
···
-
{ config, pkgs, user, ... }:
+
{ user, ... }:
{
imports = [
+3 -7
machines/pepper/hardware.nix
···
-
{ config, lib, pkgs, nixos-hardware, lanzaboote, modulesPath, ... }:
+
{ config, lib, inputs, modulesPath, ... }:
{
-
imports = [
+
imports = with inputs; [
nixos-hardware.nixosModules.framework-13-7040-amd
lanzaboote.nixosModules.lanzaboote
(modulesPath + "/installer/scan/not-detected.nix")
···
HibernateDelaySec=2h
'';
-
# set host and allow unfree
-
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
-
nixpkgs.config.allowUnfree = true;
-
-
# enable AMD microcode update and firmware
+
# enable AMD microcode update and firmware
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.enableAllFirmware = true;
+3 -7
machines/ramune/hardware.nix
···
-
{ lib, apple-silicon, modulesPath, ... }:
+
{ inputs, modulesPath, ... }:
{
-
imports = [
+
imports = with inputs; [
apple-silicon.nixosModules.apple-silicon-support
(modulesPath + "/installer/scan/not-detected.nix")
];
···
{ device = "/swap/swapfile"; }
];
-
nixpkgs = {
-
hostPlatform = lib.mkDefault "aarch64-linux";
-
config.allowUnfree = true;
-
overlays = [ apple-silicon.overlays.apple-silicon-overlay ];
-
};
+
nixpkgs.overlays = [ inputs.apple-silicon.overlays.apple-silicon-overlay ];
hardware.asahi.useExperimentalGPUDriver = true;
}
+55 -50
modules/base/nix-config.nix
···
-
{ lib, pkgs, nixpkgs, helpers, config, ... }:
+
{ lib, pkgs, inputs, helpers, config, ... }:
-
with lib; {
-
age.secrets."nix-access-tokens.conf".file = ./encrypt/nix-access-tokens.conf.age;
+
with lib; mkMerge [
+
{
+
age.secrets."nix-access-tokens.conf".file = ./encrypt/nix-access-tokens.conf.age;
-
nixpkgs.config.allowUnfree = true;
+
nix = {
+
package = pkgs.nix;
+
channel.enable = mkForce false;
-
nix = {
-
package = pkgs.nix;
-
channel.enable = mkForce false;
+
# make flake registry and nix path match flake inputs
+
registry = mkForce (mapAttrs (_: flake: {inherit flake;}) inputs);
+
nixPath = mapAttrsToList (n: _: "${n}=flake:${n}") inputs;
-
# provide for nix-shell and run
-
nixPath = [ "nixpkgs=${nixpkgs.outPath}" ];
+
settings = {
+
# save space
+
auto-optimise-store = true;
+
# Enable flakes and new 'nix' command
+
experimental-features = "nix-command flakes";
+
# disable global registry
+
flake-registry = "";
+
# Workaround for https://github.com/NixOS/nix/issues/9574
+
nix-path = config.nix.nixPath;
+
# binary caches
+
substituters = [
+
"https://cache.nixos.org"
+
"https://nix-community.cachix.org"
+
];
+
trusted-public-keys = [
+
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
+
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+
];
+
trusted-users = [ "root" "@wheel" ];
+
};
-
settings = {
-
# save space
-
auto-optimise-store = true;
-
# flakes
-
experimental-features = [ "nix-command" "flakes" ];
-
warn-dirty = false;
-
# binary caches
-
substituters = [
-
"https://cache.nixos.org"
-
"https://nix-community.cachix.org"
-
];
-
trusted-public-keys = [
-
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
-
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
-
];
-
trusted-users = [ "root" "@wheel" ];
-
};
+
# auto collect old stores
+
gc = {
+
automatic = true;
+
options = "--delete-older-than 14d";
+
} // helpers.linuxAttrs {
+
dates = "weekly";
+
} // helpers.darwinAttrs {
+
interval = { Weekday = 0; Hour = 0; Minute = 0; };
+
};
-
# auto collect old stores
-
gc = {
-
automatic = true;
-
options = "--delete-older-than 14d";
-
} // helpers.linuxAttrs {
-
dates = "weekly";
-
} // helpers.darwinAttrs {
-
interval = { Weekday = 0; Hour = 0; Minute = 0; };
+
extraOptions = ''
+
!include ${config.age.secrets."nix-access-tokens.conf".path}
+
'';
};
-
-
extraOptions = ''
-
!include ${config.age.secrets."nix-access-tokens.conf".path}
-
'';
-
};
-
} // helpers.darwinAttrs {
-
system.stateVersion = 4;
-
# Disable path verification of $NIX_PATH
-
system.checks.verifyNixPath = false;
-
# Auto upgrade nix package and the daemon service.
-
services.nix-daemon.enable = true;
-
# Auto-configure build users
-
nix.configureBuildUsers = true;
-
# Disable documentation until https://github.com/LnL7/nix-darwin/issues/217 is fixed.
-
documentation.enable = false;
-
}
+
}
+
(helpers.darwinAttrs {
+
system.stateVersion = 4;
+
# Disable path verification of $NIX_PATH
+
system.checks.verifyNixPath = false;
+
# Auto upgrade nix package and the daemon service.
+
services.nix-daemon.enable = true;
+
# Auto-configure build users
+
nix.configureBuildUsers = true;
+
# Disable documentation until https://github.com/LnL7/nix-darwin/issues/217 is fixed.
+
documentation.enable = false;
+
})
+
]