diff --git a/README.md b/README.md index c43fb60..e3c0592 100644 --- a/README.md +++ b/README.md @@ -17,21 +17,30 @@ Initialize the submodule with: git submodule update --init --recursive ``` -### Applying the configuration +### Installing and upgrading -To apply the config for the first time (e.g. on a fresh install), run this command, replacing `Shura` with the name of the host: +To apply the config for the first time (e.g. on a fresh install), run these commands, replacing `Shura` with the name of the host: ```sh +nix flake update sudo nixos-rebuild switch --flake .#Shura -``` +``` -For subsequent builds, you can omit the hostname, and/or use nh: +`nix flake update` updates the `flake.lock` file, which pins repositories to specific versions. Nix will then pull down any derivations it needs to meet the version. + +> [!NOTE] +> This config installs a [Nix wrapper called nh](https://github.com/viperML/nh). Basic install/upgrade commands can be run using `nh`, but more advanced stuff should use `nixos-rebuild`. + +For subsequent builds, you can omit the hostname: ```sh nh os switch ``` -```sh +or + +```sh +nix flake update sudo nixos-rebuild switch --flake . ``` @@ -48,15 +57,7 @@ You can build any Nix or NixOS expression on a remote system before copying it o nixos-rebuild boot --flake . --build-host haven ``` -### Upgrading - -This config installs a [Nix wrapper called nh](https://github.com/viperML/nh). To use it, run: - -```sh -nh os boot --update -``` - -You can replace `boot` with `switch`, or add `--ask` to confirm before installing. +You can also define build targets in a Nix config file. See Dimaga for an example. ### Testing diff --git a/flake.nix b/flake.nix index af156d7..72cd082 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ +# Based on the Auxolotl template: https://github.com/auxolotl/templates # For info on Flakes, see: https://nixos-and-flakes.thiscute.world/nixos-with-flakes/nixos-with-flakes-enabled - { description = "Aires' system Flake"; @@ -27,19 +27,18 @@ outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, ... }: let - inherit (self) outputs; - inherit (nixpkgs) lib; - systems = [ "x86_64-linux" "aarch64-linux" ]; - forEachSystem = f: lib.genAttrs systems (sys: f pkgsFor.${sys}); - pkgsFor = lib.genAttrs systems (system: import nixpkgs { - inherit system; - config.allowUnfree = true; - }); + forAllSystems = function: + nixpkgs.lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + ] (system: function nixpkgs.legacyPackages.${system}); + config.allowUnfree = true; # Define shared modules and imports defaultModules = { base = [ { _module.args = { inherit inputs; }; } + ./hosts/default.nix lanzaboote.nixosModules.lanzaboote nix-flatpak.nixosModules.nix-flatpak home-manager.nixosModules.home-manager { @@ -57,8 +56,9 @@ ]; }; in { + formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); nixosConfigurations = { - # Microsoft Surface Laptop Go + Dimaga = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ @@ -67,7 +67,6 @@ ]; }; - # Home server Haven = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ @@ -76,7 +75,6 @@ ]; }; - # Microsoft Surface Pro 9 Khanda = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ @@ -85,7 +83,6 @@ ]; }; - # Raspberry Pi Pihole = nixpkgs.lib.nixosSystem { system = "aarch64-linux"; modules = defaultModules.base ++ [ @@ -94,7 +91,6 @@ ]; }; - # Lenovo Legion Slim 7 Gen 7 AMD Shura = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = defaultModules.base ++ [ diff --git a/hosts/Dimaga/default.nix b/hosts/Dimaga/default.nix index 9e05a84..b9f52e5 100644 --- a/hosts/Dimaga/default.nix +++ b/hosts/Dimaga/default.nix @@ -1,12 +1,5 @@ -{ pkgs, ... }: - -# Settings specific to Dimaga - -{ - imports = [ - ./hardware-configuration.nix - ../common - ]; +{ pkgs, ... }: { + imports = [ ./hardware-configuration.nix ]; system.stateVersion = "24.05"; @@ -17,7 +10,7 @@ kdeconnect.enable = true; media.enable = true; office.enable = true; - pandoc.enable = true; + writing.enable = true; }; ui = { flatpak.enable = true; diff --git a/hosts/Dimaga/hardware-configuration.nix b/hosts/Dimaga/hardware-configuration.nix index 23c74a2..9c1b1d5 100644 --- a/hosts/Dimaga/hardware-configuration.nix +++ b/hosts/Dimaga/hardware-configuration.nix @@ -1,7 +1,5 @@ -# Surface Laptop Go -{ config, lib, pkgs, modulesPath, ... }: - -{ +# Surface Laptop Go 1st gen +{ config, lib, pkgs, modulesPath, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; diff --git a/hosts/Haven/default.nix b/hosts/Haven/default.nix index 34f2947..a736e1c 100644 --- a/hosts/Haven/default.nix +++ b/hosts/Haven/default.nix @@ -1,15 +1,9 @@ { pkgs, home-manager, lib, config, ... }: - -# Settings specific to Haven - let start-haven = pkgs.writeShellScriptBin "start-haven" (builtins.readFile ./start-haven.sh); in { - imports = [ - ./hardware-configuration.nix - ../common - ]; + imports = [ ./hardware-configuration.nix ]; system.stateVersion = "24.05"; system.autoUpgrade.enable = lib.mkForce false; diff --git a/hosts/Haven/hardware-configuration.nix b/hosts/Haven/hardware-configuration.nix index a380b19..55f945f 100644 --- a/hosts/Haven/hardware-configuration.nix +++ b/hosts/Haven/hardware-configuration.nix @@ -1,6 +1,5 @@ -{ config, lib, pkgs, modulesPath, ... }: - -{ +# Minisforum UM340 +{ config, lib, pkgs, modulesPath, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 03e33a1..4553fae 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -1,12 +1,5 @@ -{ pkgs, lib, ... }: - -# Settings specific to Dimaga - -{ - imports = [ - ./hardware-configuration.nix - ../common - ]; +{ pkgs, lib, ... }: { + imports = [ ./hardware-configuration.nix ]; system.stateVersion = "24.05"; system.autoUpgrade.enable = lib.mkForce false; diff --git a/hosts/Khanda/hardware-configuration.nix b/hosts/Khanda/hardware-configuration.nix index af4d84e..54ac70b 100644 --- a/hosts/Khanda/hardware-configuration.nix +++ b/hosts/Khanda/hardware-configuration.nix @@ -1,7 +1,5 @@ # Surface Pro 9 -{ config, lib, pkgs, modulesPath, ... }: - -{ +{ config, lib, pkgs, modulesPath, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; boot = { diff --git a/hosts/Pihole/default.nix b/hosts/Pihole/default.nix index 692a216..d4bd4a2 100644 --- a/hosts/Pihole/default.nix +++ b/hosts/Pihole/default.nix @@ -1,12 +1,5 @@ -{ pkgs, lib, ... }: - -# Settings specific to Raspberry Pi 4b - -{ - imports = [ - ./hardware-configuration.nix - ../common - ]; +{ pkgs, lib, ... }: { + imports = [ ./hardware-configuration.nix ]; system.stateVersion = "24.05"; diff --git a/hosts/Pihole/hardware-configuration.nix b/hosts/Pihole/hardware-configuration.nix index a7e6feb..ed554f3 100644 --- a/hosts/Pihole/hardware-configuration.nix +++ b/hosts/Pihole/hardware-configuration.nix @@ -1,4 +1,4 @@ -# Raspberry Pi 4 +# Raspberry Pi 4B # See https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_4 { config, lib, pkgs, modulesPath, nixos-hardware, ... }: diff --git a/hosts/Shura/default.nix b/hosts/Shura/default.nix index c5015e2..289c24c 100644 --- a/hosts/Shura/default.nix +++ b/hosts/Shura/default.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -# Configuration options unique to Shura - let # Copy bluetooth device configs shure-aonic-bluetooth = pkgs.writeText "info" (builtins.readFile ./bluetooth/shure-aonic-bluetooth-params); @@ -13,10 +10,7 @@ let monitorsConfig = pkgs.writeText "gdm_monitors.xml" monitorsXmlContent; in { - imports = [ - ./hardware-configuration.nix - ../common - ]; + imports = [ ./hardware-configuration.nix ]; system.stateVersion = "24.05"; diff --git a/hosts/Shura/hardware-configuration.nix b/hosts/Shura/hardware-configuration.nix index a078335..178cf31 100644 --- a/hosts/Shura/hardware-configuration.nix +++ b/hosts/Shura/hardware-configuration.nix @@ -1,6 +1,5 @@ -# Lenovo Legion S7 16ARHA7 configuration -{ config, lib, pkgs, modulesPath, ... }: -{ +# Lenovo Legion Slim 7 Gen 7 AMD (16ARHA7) +{ config, lib, pkgs, modulesPath, ... }: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; diff --git a/hosts/common/default.nix b/hosts/common/default.nix deleted file mode 100644 index 759ddef..0000000 --- a/hosts/common/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ lib, pkgs, ... }: -let - # Fetch secrets - # IMPORTANT: Make sure this repo exists on the filesystem first! - nix-secrets = builtins.fetchGit { - url = "/home/aires/Development/nix-configuration/nix-secrets"; - ref = "main"; - rev = "55fc814d477d956ab885e157f24c2d43f433dc7a"; - }; -in{ - imports = [ - ../../modules - "${nix-secrets}/default.nix" - ]; -} diff --git a/hosts/default.nix b/hosts/default.nix index 4052ace..d658dce 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -1,9 +1,15 @@ -{ ... }: { +{ lib, pkgs, ... }: +let + # Fetch secrets + # IMPORTANT: Make sure this repo exists on the filesystem first! + nix-secrets = builtins.fetchGit { + url = "/home/aires/Development/nix-configuration/nix-secrets"; + ref = "main"; + rev = "55fc814d477d956ab885e157f24c2d43f433dc7a"; + }; +in{ imports = [ - ./Dimaga - ./Haven - ./Khanda - ./Pihole - ./Shura + "${nix-secrets}/default.nix" + ../modules ]; -} \ No newline at end of file +}