Commit c001fb4ff6a2

Vincent Demeester <vincent@sbr.pm>
2020-05-23 18:16:29
default.nix: fix build and update hosts.nix shape
- use nixpkgs for linkFarmFromDrvs - add a way to use nixos-unstable instead of nixos for some machines - switch hokkaido to unstable (as a try) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent c118f8d
systems/hokkaido.nix
@@ -1,7 +1,7 @@
 { lib, pkgs, ... }:
 let
   dummyConfig = pkgs.writeText "configuration.nix" ''
-    assert builtins.trace "This is a dummy config, use switch!" false;
+    # assert builtins.trace "This is a dummy config, use switch!" false;
     {}
   '';
 in
systems/wakasu.nix
@@ -0,0 +1,62 @@
+{ lib, pkgs, ... }:
+let
+  dummyConfig = pkgs.writeText "configuration.nix" ''
+    # assert builtins.trace "This is a dummy config, use switch!" false;
+    {}
+  '';
+in
+{
+  imports = [
+    (import ../nix).home-manager
+    ../modules/module-list.nixos.nix
+    # hardware
+    ../hardware/thinkpad-x220.nix
+    # FIXME: remove this
+    ../machines/home.nixos.nix
+  ];
+
+  networking = {
+    hostName = "wakasu";
+  };
+
+  # FIXME move this away
+  home-manager.users.vincent = import ../home.nix;
+  home-manager.users.root = { pkgs, ... }: {
+    home.packages = with pkgs; [ htop ];
+  };
+
+  # FIXME: move this away
+  profiles.nix-config.enable = false;
+  home-manager.useGlobalPkgs = true;
+  nix.nixPath = [
+    "nixos-config=${dummyConfig}"
+    "nixpkgs=/run/current-system/nixpkgs"
+    "nixpkgs-overlays=/run/current-system/overlays/compat"
+  ];
+
+  nixpkgs = {
+    overlays = [
+      (import ../overlays/sbr.nix)
+      (import ../overlays/unstable.nix)
+      (import ../overlays/emacs-overlay)
+    ];
+    config = {
+      allowUnfree = true;
+      packageOverrides = pkgs: {
+        nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") {
+          inherit pkgs;
+        };
+      };
+    };
+  };
+
+  # FIXME: put this in a common
+  system = {
+    extraSystemBuilderCmds = ''
+      ln -sv ${pkgs.path} $out/nixpkgs
+      ln -sv ${../overlays} $out/overlays
+    '';
+
+    stateVersion = "20.03";
+  };
+}
default.nix
@@ -1,11 +1,32 @@
-{ sources ? import ./nix, lib ? sources.lib, pkgs ? sources.pkgs { } }:
+{ sources ? import ./nix
+, lib ? sources.lib
+, pkgs ? sources.pkgs { }
+, pkgs-unstable ? sources.pkgs-unstable
+, nixpkgs ? sources.nixpkgs { }
+}:
 with builtins; with lib;
 let
-  mkNixOS = name: arch:
+  /*
+  mkNixOS: make a nixos system build with the given name and cfg.
+
+  cfg is an attributeSet:
+  - arch is architecture
+  - type is weither we want to use nixos (stable) or nixos-unstable
+
+  Example:
+    hokkaido = { arch = "x86_64-linux"; };
+    honshu = { arch = "x86_64-linux"; type = "unstable"; };
+  */
+  mkNixOS = name: cfg:
     let
       configuration = ./systems + "/${name}.nix";
-      system = arch;
-      nixos = import (pkgs.path + "/nixos") { inherit configuration system; };
+      system = cfg.arch;
+      # If type == unstable, use nixos-unstable (pkgs-unstable) otherwise use nixos (pkgs)
+      p =
+        if cfg.type == "unstable"
+        then pkgs-unstable
+        else pkgs;
+      nixos = import (p.path + "/nixos") { inherit configuration system; };
     in
     nixos.config.system.build;
   mkSystem = name: arch: (mkNixOS name arch).toplevel;
@@ -19,7 +40,7 @@ let
   allSystems = attrValues systemAttrs;
 in
 {
-  systems = pkgs.linkFarmFromDrvs "systems" allSystems;
-  aarch64 = pkgs.linkFarmFromDrvs "aarch64" aarch64Systems;
-  x86_64-linux = pkgs.linkFarmFromDrvs "x86_64-linux" x86_64Systems;
+  systems = nixpkgs.linkFarmFromDrvs "systems" allSystems;
+  aarch64 = nixpkgs.linkFarmFromDrvs "aarch64" aarch64Systems;
+  x86_64-linux = nixpkgs.linkFarmFromDrvs "x86_64-linux" x86_64Systems;
 } // systemAttrs
hosts.nix
@@ -1,4 +1,5 @@
 {
-  hokkaido = "x86_64-linux";
-  # mypi = "aarch64-linux";
+  hokkaido = { arch = "x86_64-linux"; type = "unstable"; };
+  wakasu = { arch = "x86_64-linux"; };
+  # mypi = { arch = "aarch64-linux" };
 }