forked from M-Labs/nix-scripts
nixops: add rpi-3 and rpi-4
This commit is contained in:
parent
7167c34bfe
commit
ee60f202b1
|
@ -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 = {
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
From e2015bbfcbcf7594824755e39f838d7aab258b6e Mon Sep 17 00:00:00 2001
|
||||
From: Graham Christensen <graham@grahamc.com>
|
||||
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 <nixpkgs>` 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 <nixpkgs/nixos/lib/eval-config.nix> {
|
||||
+
|
||||
+ 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 <nixpkgs/nixos/lib/eval-config.nix> {
|
||||
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;
|
|
@ -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"; };
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue