diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 6af3800..666b8a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ bin/ +result +.direnv # Created by https://www.toptal.com/developers/gitignore/api/emacs # Edit at https://www.toptal.com/developers/gitignore?templates=emacs @@ -56,3 +58,39 @@ flycheck_*.el # End of https://www.toptal.com/developers/gitignore/api/emacs + +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +# *.tfvars +# *.tfvars.json +# Don't exclude them, we don't keep secrets only pinned flakes + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc \ No newline at end of file diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 0000000..df970f8 --- /dev/null +++ b/.terraform.lock.hcl @@ -0,0 +1,39 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/nomad" { + version = "1.4.16" + hashes = [ + "h1:PQxNPNmMVOErxryTWIJwr22k95DTSODmgRylqjc2TjI=", + "zh:0d4fbb7030d9caac3b123e60afa44f50c83cc2a983e1866aec7f30414abe7b0e", + "zh:0db080228e07c72d6d8ca8c45249d6f97cd0189fce82a77abbdcd49a52e57572", + "zh:0df88393271078533a217654b96f0672c60eb59570d72e6aefcb839eea87a7a0", + "zh:2883b335bb6044b0db6a00e602d6926c047c7f330294a73a90d089f98b24d084", + "zh:390158d928009a041b3a182bdd82376b50530805ae92be2b84ed7c3b0fa902a0", + "zh:7169b8f8df4b8e9659c49043848fd5f7f8473d0471f67815e8b04980f827f5ef", + "zh:9417ee1383b1edd137024882d7035be4dca51fb4f725ca00ed87729086ec1755", + "zh:a22910b5a29eeab5610350700b4899267c1b09b66cf21f7e4d06afc61d425800", + "zh:a6185c9cd7aa458cd81861058ba568b6411fbac344373a20155e20256f4a7557", + "zh:b6260ca9f034df1b47905b4e2a9c33b67dbf77224a694d5b10fb09ae92ffad4c", + "zh:d87c12a6a7768f2b6c2a59495c7dc00f9ecc52b1b868331d4c284f791e278a1e", + ] +} + +provider "registry.terraform.io/hashicorp/vault" { + version = "3.5.0" + hashes = [ + "h1:Yqv4nraqqab//lMOjNVQ6PbOmbUBzZU83IronbsQUt4=", + "zh:0db1f4cba469993952cfd3fedba4d20760ec38c9f46bcf26a92c7ac48b2d5812", + "zh:31d110c9866cd370bbd730a78a9621a8cdf226ded0f47ce4c02468365a469817", + "zh:417a00c137e2015e24069068240daf1ae4d8f0d866c54594a6a17d1e030cd2cc", + "zh:5945fe89e324ba5b3db0b1d08b2aa026f24f9d15f4876e89bd34ecf9cf5e4641", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:7f246064bd5452979f7e02eb2e97cba4e479136b7d3d7b58c2e7a2b25ea675e1", + "zh:966e508880af89d3e4e4781f90e2f781a6d3d79d2e588ea74f95f2de29bf8df9", + "zh:b1d906f534a70545117417f5672147f882730808d7338b491ea21509b794cd76", + "zh:bcfcbdfce3838741795968b1461391e45309958cf1b8ea6fd2c2c0d1cad6a7e1", + "zh:c272f4633a228d5c69cf1ad3f1acdcaf6d90f4018a3854b0c13d1053fb3e977c", + "zh:cd60fe5389f934d860f0eabe96de41898c2332ece8c7270605909ab57fe4fd14", + "zh:d3f6fa1470fa8c8041f9e391cf93b068914a1cf53ad32c05b0da114036e1a8cd", + ] +} diff --git a/containers/Add-ignored_acls-setting.patch b/containers/Add-ignored_acls-setting.patch deleted file mode 100644 index fc4a3ab..0000000 --- a/containers/Add-ignored_acls-setting.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh -index 8784d5faf..7e01b4960 100644 ---- a/src/libstore/globals.hh -+++ b/src/libstore/globals.hh -@@ -805,6 +805,15 @@ public: - may be useful in certain scenarios (e.g. to spin up containers or - set up userspace network interfaces in tests). - )"}; -+ -+ Setting ignoredAcls{ -+ this, {"security.selinux"}, "ignored-acls", -+ R"( -+ A list of ACLs that should be ignored, normally Nix attempts to -+ remove all ACLs from files and directories in the Nix store, but -+ some ACLs like `security.selinux` or `system.nfs4_acl` can't be -+ removed even by root. Therefore it's best to just ignore them. -+ )"}; - #endif - - Setting hashedMirrors{ -diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc -index 747eb205e..c6f774bc2 100644 ---- a/src/libstore/local-store.cc -+++ b/src/libstore/local-store.cc -@@ -583,9 +583,7 @@ static void canonicalisePathMetaData_(const Path & path, uid_t fromUid, InodesSe - throw SysError("querying extended attributes of '%s'", path); - - for (auto & eaName: tokenizeString(std::string(eaBuf.data(), eaSize), std::string("\000", 1))) { -- /* Ignore SELinux security labels since these cannot be -- removed even by root. */ -- if (eaName == "security.selinux") continue; -+ if (settings.ignoredAcls.get().count(eaName)) continue; - if (lremovexattr(path.c_str(), eaName.c_str()) == -1) - throw SysError("removing extended attribute '%s' from '%s'", eaName, path); - } diff --git a/containers/Ignore-system.nfs4_acl.patch b/containers/Ignore-system.nfs4_acl.patch deleted file mode 100644 index 3688dd1..0000000 --- a/containers/Ignore-system.nfs4_acl.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh -index 2f9e8c6e8..433deaf0f 100644 ---- a/src/libstore/globals.hh -+++ b/src/libstore/globals.hh -@@ -799,7 +799,7 @@ public: - )"}; - - Setting ignoredAcls{ -- this, {"security.selinux"}, "ignored-acls", -+ this, {"security.selinux", "system.nfs4_acl"}, "ignored-acls", - R"( - A list of ACLs that should be ignored, normally Nix attempts to - remove all ACLs from files and directories in the Nix store, but diff --git a/containers/hydra.nix b/containers/hydra.nix index fc4a9b5..7aae3b8 100644 --- a/containers/hydra.nix +++ b/containers/hydra.nix @@ -47,12 +47,7 @@ type.services = {}; }; nix = { - package = pkgs.nixUnstable.overrideAttrs (old: { - patches = - [ # ./Add-ignored_acls-setting.patch - # ./Ignore-system.nfs4_acl.patch - ]; - }); + package = pkgs.nixUnstable; loadNixDb = true; persistNix = "/nix-persist"; config = { diff --git a/containers/jmusicbot.nix b/containers/jmusicbot.nix deleted file mode 100644 index 8fad1be..0000000 --- a/containers/jmusicbot.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ nglib, nixpkgs }: -nglib.makeSystem { - system = "x86_64-linux"; - name = "nixng-jmusicbot"; - inherit nixpkgs; - config = ({ pkgs, config, nglib, ... }: - { - dumb-init = { - enable = true; - type.services = {}; - }; - init.services.jmusicbot = { - shutdownOnExit = true; - }; - - services.jmusicbot = { - enable = true; - - config = { - prefix = "sudo"; - token = "\${BOT_TOKEN}"; - owner = "\${BOT_OWNER}"; - }; - }; - }); -} diff --git a/flake.nix b/flake.nix index b26f65b..ee87168 100644 --- a/flake.nix +++ b/flake.nix @@ -23,126 +23,47 @@ forAllSystems' = systems: fun: nixpkgs.lib.genAttrs systems fun; forAllSystems = forAllSystems' supportedSystems; - containers = - let base = { nglib = nixng.nglib nixpkgs.lib; inherit nixpkgs; }; - in - { - hydra = (import ./containers/hydra.nix base).hydra; - hydraPostgresql = (import ./containers/hydra.nix base).postgresql; - ingressToothpick = import ./containers/ingress-toothpick.nix base; - ingressBlowhole = import ./containers/ingress-blowhole.nix base; - website = import ./containers/website.nix (base // { inherit (inputs.website) website; }); - jmusicbot = import ./containers/jmusicbot.nix base; - camptules = (import ./containers/camptules.nix (base // { inherit (inputs) camptules; })); - gitea = import ./containers/gitea.nix base; - minecraft = import ./containers/minecraft.nix base; - mosquitto = import ./containers/mosquitto.nix base; - dovecot = import ./containers/dovecot.nix base; - getmail = import ./containers/getmail base; - syncthing = import ./containers/syncthing.nix base; - zigbee2mqtt = import ./containers/zigbee2mqtt.nix base; - home-assistant = import ./containers/home-assistant.nix base; - reicio = import ./containers/reicio.nix base; - }; + pkgsForSystem = system: + import nixpkgs { inherit system; }; in - { - ociImages = mapAttrs (n: v: v.config.system.build.ociImage) containers; + { + nixngSystems = + let base = { nglib = nixng.nglib nixpkgs.lib; inherit nixpkgs; }; + in + { hydra = (import ./containers/hydra.nix base).hydra; + hydraPostgresql = (import ./containers/hydra.nix base).postgresql; + ingressToothpick = import ./containers/ingress-toothpick.nix base; + ingressBlowhole = import ./containers/ingress-blowhole.nix base; + website = import ./containers/website.nix (base // { inherit (inputs.website) website; }); + camptules = (import ./containers/camptules.nix (base // { inherit (inputs) camptules; })); + gitea = import ./containers/gitea.nix base; + minecraft = import ./containers/minecraft.nix base; + mosquitto = import ./containers/mosquitto.nix base; + dovecot = import ./containers/dovecot.nix base; + getmail = import ./containers/getmail base; + syncthing = import ./containers/syncthing.nix base; + zigbee2mqtt = import ./containers/zigbee2mqtt.nix base; + home-assistant = import ./containers/home-assistant.nix base; + reicio = import ./containers/reicio.nix base; + }; - nixngSystems = containers; - - hydraJobs = - let - pkgs = import nixpkgs { system = "x86_64-linux"; }; - makeJob = container: - pkgs.stdenv.mkDerivation - - { name = "${container.stream.imageName}-hydra-job"; - buildPhase = - '' - _workdir=$(mktemp -d) - mkdir -p $out/nix-support $out/layers - - ${container.stream} | tar -xf - -C $_workdir - for img in $_workdir/*/*.tar ; do - _hash=$(basename $(dirname $img)) - - cp $img $out/layers/$_hash.tar - done - - _config=$(basename $(find $_workdir -name '*.json' ! -name 'manifest.json' -type f)) - - cp $_workdir/manifest.json $out/manifest.json - cp $_workdir/$_config $out/$_config - - ln -s ${container.stream} $out/stream - - cat > $out/nix-support/hydra-build-products <