diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index 8d87984..89595c0 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -331,6 +331,9 @@ ACTION=="add", SUBSYSTEM=="tty", \ matterbridge = super.matterbridge.overrideAttrs(oa: { patches = oa.patches or [] ++ [ ./matterbridge-disable-github.patch ]; }); + nixops = super.nixops.overrideAttrs(oa: { + patches = oa.patches or [] ++ [ ./nixops-665.patch ]; + }); }; security.acme.certs = { diff --git a/nixbld-etc-nixos/nixops-665.patch b/nixbld-etc-nixos/nixops-665.patch new file mode 100644 index 0000000..e40299e --- /dev/null +++ b/nixbld-etc-nixos/nixops-665.patch @@ -0,0 +1,111 @@ +From e2015bbfcbcf7594824755e39f838d7aab258b6e Mon Sep 17 00:00:00 2001 +From: Graham Christensen +Date: Sat, 13 May 2017 08:53:07 -0400 +Subject: [PATCH] Support multiple versions of nixpkgs in one network + +Having a machine named foo, described as: + + foo = { # ...snipped... + deployment.nix_path.nixpkgs = (builtins.filterSource + (path: type: type != "directory" || baseNameOf path != ".git") + ./../nixpkgs); + }); + +will have the custom nixpkgs set in the `NIX_PATH` as +`nixpkgs=path-to-custom-nixpkgs`. + +Note this does not work with foo = { config, ... }: {... machines, but +having a second nix file in the network would work, and also: + + let + canary = machine: { + deployment.nix_path.nixpkgs = (builtins.filterSource + (path: type: type != "directory" || baseNameOf path != ".git") + ./../nixpkgs); + imports = [machine]; + }; + + machine = { ... }: { + # your machine config + }; + in { + machineA = machine; + machineB = canary machine; + } + +Note that because this uses scopedImport, the nixops network and +machines may use `import ` and have a consistent view of +nixpkgs. +--- + nix/eval-machine-info.nix | 35 ++++++++++++++++++++++++++++++++--- + nix/options.nix | 7 +++++++ + 2 files changed, 39 insertions(+), 3 deletions(-) + +diff --git a/nix/eval-machine-info.nix b/nix/eval-machine-info.nix +index 503b4c25d..085452cd4 100644 +--- a/nix/eval-machine-info.nix ++++ b/nix/eval-machine-info.nix +@@ -39,13 +39,42 @@ rec { + # Get the configuration of this machine from each network + # expression, attaching _file attributes so the NixOS module + # system can give sensible error messages. ++ + modules = + concatMap (n: optional (hasAttr machineName n) + { imports = [(getAttr machineName n)]; inherit (n) _file; }) + networks; +- in +- { name = machineName; +- value = import { ++ ++ machineConfs = ++ concatMap (n: optional (hasAttr machineName n) ++ (getAttr machineName n)) ++ networks; ++ ++ nameToPath = attrs: name: { ++ prefix = name; ++ path = attrs."${name}"; ++ }; ++ ++ attrsetToPaths = attrset: map (nameToPath attrset) ++ (builtins.attrNames attrset); ++ ++ importSources = ++ (concatMap (module: ++ if (!builtins.isFunction module ++ && builtins.hasAttr "deployment" module) ++ && (builtins.hasAttr "nix_path" module.deployment) ++ then attrsetToPaths module.deployment.nix_path ++ else []) ++ machineConfs) ++ builtins.nixPath; ++ ++ __nixPath = importSources; ++ ++ machineImport = builtins.scopedImport { ++ inherit __nixPath; ++ }; ++ in { ++ name = machineName; ++ value = machineImport { + modules = + modules ++ + defaults ++ +diff --git a/nix/options.nix b/nix/options.nix +index 0866c3ab8..117b44a7b 100644 +--- a/nix/options.nix ++++ b/nix/options.nix +@@ -103,6 +103,13 @@ in + ''; + }; + ++ deployment.nix_path = mkOption { ++ default = {}; ++ type = types.attrsOf types.str; ++ description = '' ++ ''; ++ }; ++ + deployment.hasFastConnection = mkOption { + default = false; + type = types.bool; diff --git a/nixops/nixops.nix b/nixops/nixops.nix index 14486ad..77aeb6f 100644 --- a/nixops/nixops.nix +++ b/nixops/nixops.nix @@ -1,5 +1,13 @@ { - rpi-1 = import ./rpi.nix { host = "rpi-1"; }; - rpi-2 = import ./rpi.nix { host = "rpi-2"; }; + rpi-1 = import ./rpi.nix { host = "rpi-1"; rpi4 = false; }; + rpi-2 = import ./rpi.nix { host = "rpi-2"; rpi4 = false; }; + rpi-3 = { + deployment.nix_path.nixpkgs = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"; + imports = [(import ./rpi.nix { host = "rpi-3"; rpi4 = true; })]; + }; + rpi-4 = { + deployment.nix_path.nixpkgs = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"; + imports = [(import ./rpi.nix { host = "rpi-4"; rpi4 = true; })]; + }; juno = import ./desktop.nix { host = "juno"; }; } diff --git a/nixops/rpi.nix b/nixops/rpi.nix index d26b8fe..327d302 100644 --- a/nixops/rpi.nix +++ b/nixops/rpi.nix @@ -1,19 +1,32 @@ -{ host }: +{ host, rpi4 }: -{ config, pkgs, lib, ... }: +{ config, pkgs, ... }: let - m-labs = import (fetchTarball https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full/nixexprs.tar.xz) {}; + m-labs = import (fetchTarball https://nixbld.m-labs.hk/channel/custom/artiq/full/artiq-full/nixexprs.tar.xz) { inherit pkgs; }; in { deployment.targetHost = host; nixpkgs.system = "aarch64-linux"; - - boot.loader.grub.enable = false; - boot.loader.generic-extlinux-compatible.enable = true; - - boot.kernelParams = ["cma=32M console=ttyS1,115200n8"]; - fileSystems = { + boot.loader.grub.enable = false; + + boot.loader.generic-extlinux-compatible.enable = !rpi4; + boot.loader.raspberryPi = pkgs.lib.mkIf rpi4 { + enable = true; + version = 4; + }; + boot.kernelPackages = pkgs.lib.mkIf rpi4 pkgs.linuxPackages_rpi4; + + fileSystems = if rpi4 then { + "/boot" = { + device = "/dev/disk/by-label/FIRMWARE"; + fsType = "vfat"; + }; + "/" = { + device = "/dev/disk/by-label/NIXOS_SD"; + fsType = "ext4"; + }; + } else { "/" = { device = "/dev/disk/by-label/NIXOS_SD"; fsType = "ext4";