Commit bc6ec6ed043e

Vincent Demeester <vincent@sbr.pm>
2022-04-19 17:02:49
systems: nix hardware and trying to fix shikoku
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 90fa577
nix/lib/default.nix
@@ -1,10 +0,0 @@
-inputs:
-
-# personal lib
-let
-  inherit (inputs.nixpkgs) lib;
-
-  home = import ./home.nix inputs;
-  system = import ./system.nix inputs;
-in
-lib // home // system
nix/lib/home.nix
@@ -1,20 +0,0 @@
-inputs:
-
-let
-  inherit (inputs) self;
-  inherit (inputs.home-manager.lib) homeManagerConfiguration;
-
-  extraSpecialArgs = { inherit inputs; };
-
-  defArgs = rec {
-    configuration = { };
-    system = "x86_64-linux";
-    inherit extraSpecialArgs;
-  };
-
-  mkHome = args: homeManagerConfiguration (defArgs // args // {
-    homeDirectory = "/home/${args.username}";
-    pkgs = inputs.self.pkgs.${args.system or defArgs.system};
-  });
-in
-{ inherit mkHome extraSpecialArgs; }
nix/lib/system.nix
@@ -1,14 +0,0 @@
-inputs:
-
-let
-  inherit (inputs.nixpkgs) lib;
-in
-rec {
-  supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
-
-  genSystems = lib.genAttrs supportedSystems;
-
-  nixpkgsFor = genSystems (system: overlays: import inputs.nixpkgs {
-    inherit system overlays;
-  });
-}
nix/shells/cargo.nix
@@ -1,21 +0,0 @@
-{ pkgs ? import <nixpkgs> { } }:
-
-# This file contains a development shell for running and working on Cargo.
-pkgs.mkShell rec {
-  name = "rustc-perf";
-  buildInputs = with pkgs; [
-    git
-    curl
-    gnumake
-    pkg-config
-    openssl
-
-    rustup
-
-    # Required for nested shells in lorri to work correctly.
-    bashInteractive
-  ];
-
-  # Always show backtraces.
-  RUST_BACKTRACE = 1;
-}
systems/hardware/lenovo-p1.nix
@@ -1,11 +1,11 @@
 { config, pkgs, lib, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
   imports = [
-    (sources.nixos-hardware + "/common/pc/ssd")
-    (sources.nixos-hardware + "/lenovo/thinkpad/p1/3th-gen")
+    #    (sources.nixos-hardware + "/common/pc/ssd")
+    #    (sources.nixos-hardware + "/lenovo/thinkpad/p1/3th-gen")
     ./thinkpad.nix
   ];
   boot = {
systems/hardware/lenovo-p50.nix
@@ -1,10 +1,10 @@
 { config, pkgs, lib, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
   imports = [
-    (sources.nixos-hardware + "/common/pc/ssd")
+    # (sources.nixos-hardware + "/common/pc/ssd")
     ./thinkpad.nix
   ];
   boot = {
systems/hardware/thinkpad-t460s.nix
@@ -1,11 +1,11 @@
 { config, pkgs, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
   imports = [
-    (sources.nixos-hardware + "/lenovo/thinkpad/t460s")
-    (sources.nixos-hardware + "/common/pc/ssd")
+    #  (sources.nixos-hardware + "/lenovo/thinkpad/t460s")
+    #  (sources.nixos-hardware + "/common/pc/ssd")
     ./thinkpad.nix
   ];
   nix.maxJobs = 12;
systems/hardware/thinkpad-t480s.nix
@@ -1,11 +1,11 @@
 { config, pkgs, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
   imports = [
-    (sources.nixos-hardware + "/lenovo/thinkpad/t480s")
-    (sources.nixos-hardware + "/common/pc/ssd")
+    #(sources.nixos-hardware + "/lenovo/thinkpad/t480s")
+    #(sources.nixos-hardware + "/common/pc/ssd")
     ./thinkpad.nix
   ];
   boot = {
systems/hardware/thinkpad-x220.nix
@@ -1,13 +1,13 @@
 { config, pkgs, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
   imports = [
     ./thinkpad.nix
-    (sources.nixos-hardware + "/lenovo/thinkpad/tp-smapi.nix")
-    (sources.nixos-hardware + "/common/cpu/intel")
-    (sources.nixos-hardware + "/common/pc/ssd")
+    #(sources.nixos-hardware + "/lenovo/thinkpad/tp-smapi.nix")
+    #(sources.nixos-hardware + "/common/cpu/intel")
+    #(sources.nixos-hardware + "/common/pc/ssd")
   ];
   boot = {
     kernelParams = [ "i915.enable_psr=1" ];
systems/hardware/thinkpad.nix
@@ -1,9 +1,9 @@
 { config, pkgs, ... }:
-let
-  sources = import ../../nix/sources.nix;
-in
+#let
+#  sources = import ../../nix/sources.nix;
+#in
 {
-  imports = [ (sources.nixos-hardware + "/lenovo/thinkpad") ];
+  #imports = [ (sources.nixos-hardware + "/lenovo/thinkpad") ];
   boot = {
     blacklistedKernelModules = [
       # Kernel GPU Savings Options (NOTE i915 chipset only)
systems/hosts/shikoku.nix
@@ -14,14 +14,13 @@ let
 in
 {
   imports = [
-    (import ../../nix).home-manager-stable
-    ../modules/default.stable.nix
+    # (import ../../nix).home-manager-stable
+    #../modules/default.stable.nix
     (import ../../users).vincent
     (import ../../users).root
   ];
 
   networking = {
-    hostName = hostname;
     bridges.br1.interfaces = [ "enp0s31f6" ];
     firewall.enable = false; # we are in safe territory :D
     useDHCP = false;
@@ -60,9 +59,9 @@ in
   # swapDevices = [{ device = "/dev/disk/by-uuid/720200fc-8f27-49a7-85bb-a406b6119d31"; }];
 
   profiles = {
-    home = true;
-    dev.enable = false;
-    desktop.enable = lib.mkForce false;
+    #home = true;
+    dev.enable = lib.mkForce false;
+    #desktop.enable = lib.mkForce false;
     avahi.enable = true;
     syncthing.enable = true;
     ssh = { enable = true; };
systems/modules/default.flake.nix
@@ -1,10 +0,0 @@
-{
-  imports = [
-    ./core
-    ./hardware
-    ./profiles
-    ./programs
-    ./services
-    ./virtualisation
-  ];
-}
users/profiles.nix
@@ -1,39 +0,0 @@
-inputs:
-
-let
-  inherit (inputs) self;
-  inherit (self.lib) mkHome extraSpecialArgs;
-
-  sharedModules = [
-    # ../.
-    # ../files
-    # ../shell
-    # ../games.nix
-    # ../media.nix
-  ];
-
-  homeImports = {
-    "vincent@naruhodo" = sharedModules ++ [ ../wayland ./mihai-io ../editors/emacs ];
-    # "vincent@aomi" = sharedModules ++ [ ../wayland ./mihai-tosh ];
-    "vincent@okinawa" = sharedModules ++ [ ../wayland ./mihai-tosh ];
-    server = [ ../cli.nix ];
-  };
-in
-{
-  inherit homeImports extraSpecialArgs;
-
-  homeConfigurations = {
-    "vincent@naruhodo" = {
-      username = "vincent";
-      extraModules = homeImports."vincent@naruhodo";
-    };
-    "vincent@okinawa" = {
-      username = "vincent";
-      extraModules = homeImports."vincent@naruhodo";
-    };
-    "server" = {
-      username = "vincent";
-      extraModules = homeImports.server;
-    };
-  };
-}
flake.lock
@@ -249,6 +249,21 @@
         "type": "github"
       }
     },
+    "nix-hardware": {
+      "locked": {
+        "lastModified": 1649849514,
+        "narHash": "sha256-zQyTr2UebTKUh1KLyLtevhHsM8umPK1LfQLGUGjRjiQ=",
+        "owner": "NixOS",
+        "repo": "nixos-hardware",
+        "rev": "1a0ccdbf4583ed0fce37eea7955e8ef90f840a9f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "repo": "nixos-hardware",
+        "type": "github"
+      }
+    },
     "nixos-21_11": {
       "locked": {
         "lastModified": 1650244918,
@@ -265,6 +280,20 @@
         "type": "github"
       }
     },
+    "nixos-hardware": {
+      "locked": {
+        "lastModified": 1649849514,
+        "narHash": "sha256-zQyTr2UebTKUh1KLyLtevhHsM8umPK1LfQLGUGjRjiQ=",
+        "owner": "NixOS",
+        "repo": "nixos-hardware",
+        "rev": "1a0ccdbf4583ed0fce37eea7955e8ef90f840a9f",
+        "type": "github"
+      },
+      "original": {
+        "id": "nixos-hardware",
+        "type": "indirect"
+      }
+    },
     "nixos-unstable": {
       "locked": {
         "lastModified": 1650161686,
@@ -378,7 +407,9 @@
         "home-manager": "home-manager",
         "home-manager-stable": "home-manager-stable",
         "impermanence": "impermanence",
+        "nix-hardware": "nix-hardware",
         "nixos-21_11": "nixos-21_11",
+        "nixos-hardware": "nixos-hardware",
         "nixos-unstable": "nixos-unstable",
         "nixos-wsl": "nixos-wsl",
         "nixpkgs": "nixpkgs_2",
flake.nix
@@ -44,6 +44,7 @@
 
     # WSL
     nixos-wsl = { type = "github"; owner = "nix-community"; repo = "NixOS-WSL"; inputs.nixpkgs.follows = "nixpkgs"; };
+    nix-hardware = { type = "github"; owner = "NixOS"; "repo" = "nixos-hardware"; };
 
     # Channels
     # FIXME: is it needed or should I just alias nixos-unstable instead
@@ -64,14 +65,19 @@
     , sops-nix
     , envfs
     , nixos-wsl
+    , nixos-hardware
     , ...
     } @ inputs:
     let
       mkApp = flake-utils.lib.mkApp;
       # homeProfiles = import ./home { inherit (nixpkgs) lib; };
+
+      nixosModules = flake-utils-plus.lib.exportModules [
+        ./systems/modules/virtualisation/buildkit.nix
+      ];
     in
     flake-utils-plus.lib.mkFlake {
-      inherit self inputs;
+      inherit self inputs nixosModules;
 
       supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
       channelsConfig.allowUnfree = true;
@@ -89,13 +95,41 @@
           # nixos/profiles/core.nix requires self parameter
           inherit self;
         };
-        modules = [
+        modules = with nixosModules; [
+          # Exported modules
+          buildkit
           # Common modules
-          ./systems/modules/default.flake.nix # FIXME rename to default.nix once all is migrated
+          # FIXME: migrate this to elsewhere, or at least split it
+          ./systems/modules/core/nix.nix
+          ./systems/modules/core/users.nix
+          ./systems/modules/profiles/base.nix
+          ./systems/modules/profiles/syncthing.nix
+          ./systems/modules/profiles/avahi.nix
+          ./systems/modules/profiles/ssh.nix
+          ./systems/modules/profiles/virtualization.nix
+          ./systems/modules/profiles/yubikey.nix
+          ./systems/modules/profiles/dev.nix
+          ./systems/modules/profiles/git.nix
+          ./systems/modules/profiles/desktop.nix
+          ./systems/modules/profiles/laptop.nix
+          ./systems/modules/profiles/gnome.nix
+          ./systems/modules/profiles/printing.nix
+          ./systems/modules/profiles/pulseaudio.nix
+          ./systems/modules/profiles/scanning.nix
+          ./systems/modules/hardware/sane-extra-config.nixos.nix
+          ./systems/modules/profiles/redhat.nix
+          ./systems/modules/profiles/i3.nix
+          ./systems/modules/profiles/sway.nix
+          ./systems/modules/profiles/builder.nix
+          ./systems/modules/profiles/home.nix
+          ./systems/modules/services/wireguard.client.nix
           home-manager.nixosModules.home-manager
           sops-nix.nixosModules.sops
           envfs.nixosModules.envfs
           {
+            config.nix.generateRegistryFromInputs = true;
+            config.home-manager.useGlobalPkgs = true;
+            config.home-manager.useUserPackages = true;
             # Import custom home-manager modules (NixOS)
             config.home-manager.sharedModules = import ./users/modules/modules.nix;
             # Default SopsFile
@@ -107,12 +141,18 @@
       hosts = {
         # Main laptop
         naruhodo = {
-          modules = [ ./systems/hosts/naruhodo.nix ];
+          modules = [
+            nixos-hardware.nixosModules.lenovo-thinkpad-t480s
+            nixos-hardware.nixosModules.common-pc-laptop-ssd
+            ./systems/modules/profiles/docker.nix
+            ./systems/hosts/naruhodo.nix
+          ];
         };
         # WSL setup
         # FIXME okinawa doesn't have openssh
         okinawa = {
           modules = [
+            ./systems/modules/profiles/docker.nix
             nixos-wsl.nixosModules.wsl
             ./systems/hosts/okinawa.nix
           ];
@@ -120,23 +160,39 @@
         # Servers
         shikoku = {
           channelName = "nixos-21_11";
-          modules = [ ./systems/hosts/shikoku.nix ]; # Can add additionnal things
+          modules = [
+            ./systems/modules/profiles/docker.stable.nix
+            ./systems/hosts/shikoku.nix
+          ];
         };
         wakasu = {
           channelName = "nixos-21_11";
-          modules = [ ./systems/hosts/wakasu.nix ]; # Can add additionnal things
+          modules = [
+            nixos-hardware.nixosModules.lenovo-thinkpad
+            nixos-hardware.nixosModules.common-pc-laptop-ssd
+            ./systems/hosts/wakasu.nix
+          ];
         };
         sakhalin = {
           channelName = "nixos-21_11";
-          modules = [ ./systems/hosts/sakhalin.nix ]; # Can add additionnal things
+          modules = [
+            nixos-hardware.nixosModules.common-pc-ssd
+            ./systems/hosts/sakhalin.nix
+          ];
         };
         aomi = {
           channelName = "nixos-21_11";
-          modules = [ ./systems/hosts/aomi.nix ]; # Can add additionnal things
+          modules = [
+            nixos-hardware.nixosModules.lenovo-thinkpad-p1-3th-gen
+            nixos-hardware.nixosModules.common-pc-laptop-ssd
+            ./systems/hosts/aomi.nix
+          ];
         };
         kerkouane = {
           channelName = "nixos-21_11";
-          modules = [ ./systems/hosts/kerkouane.nix ]; # Can add additionnal things
+          modules = [
+            ./systems/hosts/kerkouane.nix
+          ];
         };
       };
 
home.nix
@@ -1,24 +0,0 @@
-# This configuration file simply determines the hostname and then import both
-# the default configuration (common for all machine) and specific machine
-# configuration.
-let
-  hostName = "${builtins.readFile ./hostname}";
-  home-manager = (import ./nix/sources.nix).home-manager;
-in
-{
-  programs = {
-    home-manager = {
-      enable = true;
-      path = "${home-manager}";
-    };
-  };
-  nixpkgs.overlays = [
-    (import ./overlays/sbr.nix)
-    (import ./overlays/unstable.nix)
-    (import ./nix).emacs
-  ];
-  imports = [
-    # Machine specific configuration files
-    (./systems + "/${hostName}.home.nix")
-  ];
-}