home

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c001fb4ff6a2616537f6ed1a152cb062384db994
parent c118f8d8181a40e2a6f208f35518653316abd7e7
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Sat, 23 May 2020 18:16:29 +0200

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>

Diffstat:
Mdefault.nix | 35++++++++++++++++++++++++++++-------
Mhosts.nix | 5+++--
Msystems/hokkaido.nix | 2+-
Asystems/wakasu.nix | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+), 10 deletions(-)

diff --git a/default.nix b/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 diff --git a/hosts.nix b/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" }; } diff --git a/systems/hokkaido.nix b/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 diff --git a/systems/wakasu.nix b/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"; + }; +}