nixos-config/krops.nix

104 lines
3.1 KiB
Nix
Raw Normal View History

2021-03-12 20:35:48 +01:00
{ config ? config, name, target ? name , buildTarget ? target }: let
2018-10-07 17:08:01 +02:00
krops = ../submodules/krops;
2019-04-12 20:42:32 +02:00
nixpkgs-src = lib.importJSON ../krebs/nixpkgs.json;
2018-08-29 00:24:34 +02:00
2018-09-08 12:01:42 +02:00
lib = import "${krops}/lib";
2018-08-29 00:24:34 +02:00
pkgs = import "${krops}/pkgs" {};
2018-09-08 12:01:42 +02:00
host-src = {
2018-08-29 00:24:34 +02:00
secure = false;
torrent = false;
hw = false;
musnix = false;
python = false;
unstable = false; #unstable channel checked out
mic92 = false;
nms = false;
2018-09-17 00:24:05 +02:00
arm6 = false;
2018-08-29 00:24:34 +02:00
clever_kexec = false;
2018-09-19 02:53:18 +02:00
home-manager = false;
2018-08-29 00:24:34 +02:00
} // import (./. + "/1systems/${name}/source.nix");
source = { test }: lib.evalSource [
{
2018-11-30 23:18:53 +01:00
nixpkgs = if host-src.arm6 then {
# TODO: we want to track the unstable channel
symlink = "/nix/var/nix/profiles/per-user/root/channels/nixos/";
} else {
derivation = ''
2021-12-08 12:27:11 +01:00
with import (builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${nixpkgs-src.rev}.tar.gz";
sha256 = "${nixpkgs-src.sha256}";
}) {};
pkgs.fetchFromGitHub {
owner = "nixos";
2018-11-27 21:06:20 +01:00
repo = "nixpkgs";
rev = "${nixpkgs-src.rev}";
sha256 = "${nixpkgs-src.sha256}";
}
'';
2018-08-29 00:24:34 +02:00
};
nixos-config.symlink = "stockholm/makefu/1systems/${name}/config.nix";
2018-09-08 12:01:42 +02:00
stockholm.file = toString ./..;
2018-08-29 00:24:34 +02:00
secrets = if test then {
2018-09-08 12:01:42 +02:00
file = toString ./0tests/data/secrets;
2018-08-29 00:24:34 +02:00
} else {
pass = {
dir = "${lib.getEnv "HOME"}/.secrets-pass";
inherit name;
};
};
}
(lib.mkIf (host-src.unstable) {
nixpkgs-unstable.git = {
2020-10-18 19:07:43 +02:00
url = "https://github.com/nixos/nixpkgs";
ref = (lib.importJSON ../krebs/nixpkgs-unstable.json).rev;
};
})
2018-09-08 12:01:42 +02:00
(lib.mkIf (host-src.torrent) {
2018-08-29 00:24:34 +02:00
torrent-secrets = if test then {
2018-09-08 12:01:42 +02:00
file = toString ./0tests/data/secrets;
2018-08-29 00:24:34 +02:00
} else {
pass = {
dir = "${lib.getEnv "HOME"}/.secrets-pass";
name = "torrent";
};
};
})
2018-09-08 12:01:42 +02:00
(lib.mkIf ( host-src.musnix ) {
2018-08-29 00:24:34 +02:00
musnix.git = {
url = https://github.com/musnix/musnix.git;
ref = "master"; # follow the musnix channel, lets see how this works out
};
})
2018-09-08 12:01:42 +02:00
(lib.mkIf ( host-src.hw ) {
2018-08-29 00:24:34 +02:00
nixos-hardware.git = {
url = https://github.com/nixos/nixos-hardware.git;
2021-01-27 23:26:20 +01:00
ref = "a0d8383";
2018-08-29 00:24:34 +02:00
};
})
2018-09-19 02:53:18 +02:00
(lib.mkIf ( host-src.home-manager ) {
home-manager.git = {
url = https://github.com/rycee/home-manager;
2021-12-05 14:38:46 +01:00
ref = "6ce1d64073f48b9bc9425218803b1b607454c1e7";
2018-09-19 02:53:18 +02:00
};
})
2018-08-29 00:24:34 +02:00
];
in {
# usage: $(nix-build --no-out-link --argstr name HOSTNAME -A deploy)
deploy = pkgs.krops.writeDeploy "${name}-deploy" {
source = source { test = false; };
2021-03-15 21:32:29 +01:00
fast = true;
2018-09-08 12:01:42 +02:00
target = "root@${target}/var/src";
2021-03-12 20:35:48 +01:00
buildTarget = if target == buildTarget then "root@${target}/var/src" else "root@${buildTarget}/tmp/";
2018-08-29 00:24:34 +02:00
};
# usage: $(nix-build --no-out-link --argstr name HOSTNAME --argstr target PATH -A test)
test = { target ? target }: pkgs.krops.writeTest "${name}-test" {
2018-10-09 13:48:52 +02:00
force = true;
inherit target;
2018-08-29 00:24:34 +02:00
source = source { test = true; };
2018-09-08 12:10:45 +02:00
};
2018-08-29 00:24:34 +02:00
}