From 4d1af7a40dc3d6775d125ceb3772dcc693428349 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 13 Apr 2023 19:21:12 +0200 Subject: [PATCH 1/4] initial flake for system configuration --- flake.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c2758b0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,15 @@ +{ + description = "NixOS system flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; + }; + + outputs = { self, nixpkgs }: { + + nixosConfigurations.thinknix = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ ./nixos/configuration.nix ]; + }; + }; +} From d493ea127a8bb02cbd70da693cd116675ac31aa4 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 13 Apr 2023 19:28:45 +0200 Subject: [PATCH 2/4] fix impure hardware configuration import --- nixos/hardware-configuration.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix index 77fed4a..a08e812 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, modulesPath, ... }: let @@ -7,7 +7,7 @@ in { imports = [ - + (modulesPath + "/installer/scan/not-detected.nix") ( builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware"; From 62364a9db522961a0ca80e54a756d99c8d579da1 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 13 Apr 2023 19:57:56 +0200 Subject: [PATCH 3/4] expose all flake inputs to NixOS system path and registry --- flake.nix | 5 ++++- nixos/configuration.nix | 27 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index c2758b0..55a7961 100644 --- a/flake.nix +++ b/flake.nix @@ -3,13 +3,16 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; + nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs }: { + outputs = { self, nixpkgs, ... }@inputs: { nixosConfigurations.thinknix = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./nixos/configuration.nix ]; + # necessary to make the top-level inputs available to system configuration + specialArgs = { inherit inputs; }; }; }; } diff --git a/nixos/configuration.nix b/nixos/configuration.nix index af6b0f3..df6224e 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -2,10 +2,10 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, ... }: +{ config, pkgs, lib, inputs, ... }: let - unstable = import { }; + unstable = inputs.nixos-unstable; localfork = import /home/spiollinux/src/nixpkgs { }; in @@ -234,15 +234,22 @@ in # Enable all sysrq functions (useful to recover from some issues): boot.kernel.sysctl."kernel.sysrq" = 1; # NixOS default: 16 (only the sync command) + nix = { + # expose all flake inputs through nix Path and registry + registry = (lib.mapAttrs (_: value: { flake = value; }) inputs) // { + nixpkgs.flake = inputs.nixpkgs; + }; + nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry; # keep build-time deps around for offline-rebuilding - nix.settings = { - # keep around all inputs necessary for offline-rebuilding the system - keep-outputs = true; - keep-derivations = true; - trusted-users = [ "spiollinux" ]; - experimental-features = [ "nix-command" "flakes" ]; - # use all cores for building - cores = 0; + settings = { + # keep around all inputs necessary for offline-rebuilding the system + keep-outputs = true; + keep-derivations = true; + trusted-users = [ "spiollinux" ]; + experimental-features = [ "nix-command" "flakes" ]; + # use all cores for building + cores = 0; + }; }; # override tmpdir for daemon #systemd.services.nix-daemon.environment.TMPDIR = "/var/tmp"; From 339938b21365ae100221b3b345fbb2b90c2da07b Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 13 Apr 2023 20:34:56 +0200 Subject: [PATCH 4/4] use nixos-hardware from flake inputs --- flake.nix | 1 + nixos/hardware-configuration.nix | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 55a7961..f60b817 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; outputs = { self, nixpkgs, ... }@inputs: { diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix index a08e812..4c1b5c1 100644 --- a/nixos/hardware-configuration.nix +++ b/nixos/hardware-configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, pkgs, modulesPath, inputs, ... }: let @@ -8,12 +8,7 @@ in imports = [ (modulesPath + "/installer/scan/not-detected.nix") - ( - builtins.fetchGit { - url = "https://github.com/NixOS/nixos-hardware"; - rev = "a4bc66709604ab78abc575b60baa6d23ae027a59"; - } + "/lenovo/thinkpad/t440s" - ) + (inputs.nixos-hardware + "/lenovo/thinkpad/t440s") ]; boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];