From ae2f945f421843c8836b6e734f4435bdab964233 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 29 Jan 2023 02:39:19 +0100 Subject: [PATCH 1/7] devshell: remove unnecessary input See: https://github.com/divnix/digga/commit/7646c7dac4167a3da62d6f92d1d67618529b42e5 --- shell/devos.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/devos.nix b/shell/devos.nix index 5a922b4b..c216f3b9 100644 --- a/shell/devos.nix +++ b/shell/devos.nix @@ -17,6 +17,7 @@ shellcheck shfmt treefmt + nixos-generators ; inherit @@ -62,7 +63,7 @@ in { (devos cachix) ] ++ lib.optionals (pkgs.stdenv.hostPlatform.isLinux && !pkgs.stdenv.buildPlatform.isDarwin) [ - (devos inputs.nixos-generators.defaultPackage.${pkgs.system}) + (devos nixos-generators) (devos deploy-rs) ]; } From 158f336517aeede79b8fdaa25b460519a6a051f7 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 29 Jan 2023 02:40:14 +0100 Subject: [PATCH 2/7] base-user: fix home-manager stateVersion See: https://github.com/divnix/digga/commit/bca4b89f497b8553dd9c0006e85c65e3e2937743 --- flake.lock | 151 ++++++------------------------------ flake.nix | 11 ++- profiles/base-user/home.nix | 10 --- 3 files changed, 30 insertions(+), 142 deletions(-) diff --git a/flake.lock b/flake.lock index f62e3e63..80352d50 100644 --- a/flake.lock +++ b/flake.lock @@ -20,21 +20,6 @@ "type": "github" } }, - "blank": { - "locked": { - "lastModified": 1625557891, - "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", - "owner": "divnix", - "repo": "blank", - "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", - "type": "github" - }, - "original": { - "owner": "divnix", - "repo": "blank", - "type": "github" - } - }, "darwin": { "inputs": { "nixpkgs": [ @@ -63,11 +48,11 @@ ] }, "locked": { - "lastModified": 1651916036, - "narHash": "sha256-UuD9keUGm4IuVEV6wdSYbuRm7CwfXE63hVkzKDjVsh4=", + "lastModified": 1672753581, + "narHash": "sha256-EIi2tqHoje5cE9WqH23ZghW28NOOWSUM7tcxKE1U9KI=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "2f2bdf658d2b79bada78dc914af99c53cad37cba", + "rev": "3db1d870b04b13411f56ab1a50cd32b001f56433", "type": "github" }, "original": { @@ -107,11 +92,11 @@ ] }, "locked": { - "lastModified": 1655976588, - "narHash": "sha256-VreHyH6ITkf/1EX/8h15UqhddJnUleb0HgbC3gMkAEQ=", + "lastModified": 1671489820, + "narHash": "sha256-qoei5HDJ8psd1YUPD7DhbHdhLIT9L2nadscp4Qk37uk=", "owner": "numtide", "repo": "devshell", - "rev": "899ca4629020592a13a46783587f6e674179d1db", + "rev": "5aa3a8039c68b4bf869327446590f4cdf90bb634", "type": "github" }, "original": { @@ -122,18 +107,17 @@ }, "digga": { "inputs": { - "blank": "blank", "darwin": "darwin_2", "deploy": [ "deploy" ], "devshell": "devshell", "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", "flake-utils-plus": "flake-utils-plus", "home-manager": [ "home" ], - "latest": "latest", "nixlib": [ "nixos" ], @@ -143,11 +127,11 @@ "nixpkgs-unstable": "nixpkgs-unstable" }, "locked": { - "lastModified": 1661600857, - "narHash": "sha256-KfQCcTtfvU0PXV4fD9XKIMcKx9lUUR0xWJoBgc12fKE=", + "lastModified": 1674947971, + "narHash": "sha256-6gKqegJHs72jnfFP9g2sihl4fIZgtKgKuqU2rCkIdGY=", "owner": "pub-solar", "repo": "digga", - "rev": "c902b3ef0aa45cb4f336c390f647bb182c38a221", + "rev": "2da608bd8afb48afef82c6b1b6d852a36094a497", "type": "github" }, "original": { @@ -176,11 +160,11 @@ "flake-compat_2": { "flake": false, "locked": { - "lastModified": 1650374568, - "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", "type": "github" }, "original": { @@ -222,7 +206,10 @@ }, "flake-utils-plus": { "inputs": { - "flake-utils": "flake-utils_2" + "flake-utils": [ + "digga", + "flake-utils" + ] }, "locked": { "lastModified": 1654029967, @@ -241,11 +228,11 @@ }, "flake-utils_2": { "locked": { - "lastModified": 1644229661, - "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -277,22 +264,6 @@ } }, "latest": { - "locked": { - "lastModified": 1657265485, - "narHash": "sha256-PUQ9C7mfi0/BnaAUX2R/PIkoNCb/Jtx9EpnhMBNrO/o=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "b39924fc7764c08ae3b51beef9a3518c414cdb7d", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "latest_2": { "locked": { "lastModified": 1674641431, "narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=", @@ -308,41 +279,6 @@ "type": "github" } }, - "naersk": { - "inputs": { - "nixpkgs": [ - "nixos" - ] - }, - "locked": { - "lastModified": 1671096816, - "narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=", - "owner": "nmattia", - "repo": "naersk", - "rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114", - "type": "github" - }, - "original": { - "owner": "nmattia", - "repo": "naersk", - "type": "github" - } - }, - "nixlib": { - "locked": { - "lastModified": 1636849918, - "narHash": "sha256-nzUK6dPcTmNVrgTAC1EOybSMsrcx+QrVPyqRdyKLkjA=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "28a5b0557f14124608db68d3ee1f77e9329e9dd5", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, "nixos": { "locked": { "lastModified": 1674868155, @@ -359,25 +295,6 @@ "type": "github" } }, - "nixos-generators": { - "inputs": { - "nixlib": "nixlib", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1674666581, - "narHash": "sha256-KNI2s/xrL7WOYaPJAWKBtb7cCH3335rLfsL+B+ssuGY=", - "owner": "nix-community", - "repo": "nixos-generators", - "rev": "6a5dc1d3d557ea7b5c19b15ff91955124d0400fa", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixos-generators", - "type": "github" - } - }, "nixos-hardware": { "locked": { "lastModified": 1674550793, @@ -393,34 +310,18 @@ "type": "github" } }, - "nixpkgs": { - "locked": { - "lastModified": 1637186689, - "narHash": "sha256-NU7BhgnwA/3ibmCeSzFK6xGi+Bari9mPfn+4cBmyEjw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "7fad01d9d5a3f82081c00fb57918d64145dc904c", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-unstable": { "locked": { - "lastModified": 1657292830, - "narHash": "sha256-ldfVSTveWceDCmW6gf3B4kR6vwmz/XS80y5wsLLHFJU=", + "lastModified": 1672791794, + "narHash": "sha256-mqGPpGmwap0Wfsf3o2b6qHJW1w2kk/I6cGCGIU+3t6o=", "owner": "nixos", "repo": "nixpkgs", - "rev": "334ec8b503c3981e37a04b817a70e8d026ea9e84", + "rev": "9813adc7f7c0edd738c6bdd8431439688bb0cb3d", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } @@ -445,10 +346,8 @@ "digga": "digga", "flake-compat": "flake-compat_3", "home": "home", - "latest": "latest_2", - "naersk": "naersk", + "latest": "latest", "nixos": "nixos", - "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", "nur": "nur" } diff --git a/flake.nix b/flake.nix index 33ce736f..7bec396d 100644 --- a/flake.nix +++ b/flake.nix @@ -31,12 +31,7 @@ agenix.url = "github:ryantm/agenix"; agenix.inputs.nixpkgs.follows = "nixos"; - naersk.url = "github:nmattia/naersk"; - naersk.inputs.nixpkgs.follows = "nixos"; - nixos-hardware.url = "github:nixos/nixos-hardware"; - - nixos-generators.url = "github:nix-community/nixos-generators"; }; outputs = { @@ -144,7 +139,11 @@ }; }; users = { - pub-solar = {suites, ...}: {imports = suites.base;}; + pub-solar = {suites, ...}: { + imports = suites.base; + + home.stateVersion = "21.03"; + }; }; # digga.lib.importers.rakeLeaves ./users/hm; }; diff --git a/profiles/base-user/home.nix b/profiles/base-user/home.nix index 27a7c32c..9c964515 100644 --- a/profiles/base-user/home.nix +++ b/profiles/base-user/home.nix @@ -88,15 +88,5 @@ in { # Allow unfree packages only on a user basis, not on a system-wide basis xdg.configFile."nixpkgs/config.nix".text = " { allowUnfree = true; } "; - - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - home.stateVersion = "21.03"; }; } From 155237dec79045be6d287922d40dcf90f514f3b9 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 29 Jan 2023 02:46:53 +0100 Subject: [PATCH 3/7] drone: add --accept-flake-config flag --- .drone.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index b4d4bb92..10c3f4ee 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: event: - pull_request environment: - NIX_FLAGS: "--print-build-logs --verbose" + NIX_FLAGS: "--print-build-logs --verbose --accept-flake-config" commands: - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - nix $$NIX_FLAGS develop --command nix flake show @@ -27,7 +27,7 @@ node: steps: - name: "Tests" environment: - NIX_FLAGS: "--print-build-logs --verbose" + NIX_FLAGS: "--print-build-logs --verbose --accept-flake-config" commands: - 'echo DEBUG: Using NIX_FLAGS: $NIX_FLAGS' - nix $$NIX_FLAGS build ".#checks.x86_64-linux.customTestFor-PubSolarOS-firstTest" @@ -93,7 +93,7 @@ steps: - name: "Build ISO" image: docker.nix-community.org/nixpkgs/nix-flakes:latest environment: - NIX_FLAGS: "--print-build-logs --verbose" + NIX_FLAGS: "--print-build-logs --verbose --accept-flake-config" volumes: - name: file-exchange path: /var/nix/iso-cache @@ -148,6 +148,6 @@ volumes: --- kind: signature -hmac: 291be33bbf2954d1f5e4bf569679e24a773e7d6f90db4765fb9dacb3686a825e +hmac: f388f4c8d7722725140a201f8f86dd9baa480e66d495d2ad26e075ae1c2012db ... From 164c0f8fb33b1c4520da9e080100add4324ddebd Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sun, 29 Jan 2023 17:38:00 +0100 Subject: [PATCH 4/7] drone: fix path for ISO upload on flora-6 --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 10c3f4ee..2a9c496d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -126,7 +126,7 @@ steps: from_secret: iso_web_ssh_port key: from_secret: iso_web_ssh_key - target: /srv/os/download + target: /srv/www/os/download source: - /var/nix/iso-cache/*.iso - /var/nix/iso-cache/*.iso.sha256 @@ -148,6 +148,6 @@ volumes: --- kind: signature -hmac: f388f4c8d7722725140a201f8f86dd9baa480e66d495d2ad26e075ae1c2012db +hmac: 0c0994f0878cdb49172772f78c9a772f5c75830b49c1c22bd15db385fe857e17 ... From 289b58198c489fc20d0f3a546f5aa058b56d0457 Mon Sep 17 00:00:00 2001 From: Hendrik Sokolowski Date: Sat, 22 Oct 2022 14:57:40 +0200 Subject: [PATCH 5/7] NixOS module for a drone ci runner in docker --- modules/docker-ci-runner/default.nix | 105 +++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 modules/docker-ci-runner/default.nix diff --git a/modules/docker-ci-runner/default.nix b/modules/docker-ci-runner/default.nix new file mode 100644 index 00000000..2a32b8fa --- /dev/null +++ b/modules/docker-ci-runner/default.nix @@ -0,0 +1,105 @@ +{ lib, config, pkgs, self, ... }: + +with lib; +let + bootstrap = pkgs.writeScript "bootstrap.sh" '' + #!/usr/bin/env bash + + set -e + + apt update + apt install --yes curl git sudo xz-utils + + adduser --system --uid 999 build + chown build /nix + + sudo -u build curl -L https://nixos.org/nix/install > install + sudo -u build sh install + + echo "export PATH=/nix/var/nix/profiles/per-user/build/profile/bin:''$PATH" >> /etc/profile + + mkdir /etc/nix + echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf + + export nix_user_config_file="/home/build/.local/share/nix/trusted-settings.json" + mkdir -p $(dirname \\$nix_user_config_file) + echo '{"extra-experimental-features":{"nix-command flakes":true},"extra-substituters":{"https://nix-dram.cachix.org https://dram.cachix.org https://nrdxp.cachix.org https://nix-community.cachix.org":true},"extra-trusted-public-keys":{"nix-dram.cachix.org-1:CKjZ0L1ZiqH3kzYAZRt8tg8vewAx5yj8Du/+iR8Efpg= dram.cachix.org-1:baoy1SXpwYdKbqdTbfKGTKauDDeDlHhUpC+QuuILEMY= nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=":true}}' > \\$nix_user_config_file + chown -R build /home/build/ + + curl -L https://github.com/drone-runners/drone-runner-exec/releases/latest/download/drone_runner_exec_linux_amd64.tar.gz | tar xz + sudo install -t /usr/local/bin drone-runner-exec + + if [ ! -f /run/vars ]; then + exit 1 + fi + + cp -a /run/vars /run/runtime-vars + env | grep "DRONE" >> /run/runtime-vars + + su - -s /bin/bash build sh -c "/usr/local/bin/drone-runner-exec daemon /run/runtime-vars" + ''; + psCfg = config.pub-solar; + cfg = config.pub-solar.docker-ci-runner; +in +{ + options.pub-solar.docker-ci-runner = { + enable = lib.mkEnableOption "Enables a systemd service that runs drone-ci-runner"; + + enableKvm = lib.mkOption { + description = '' + Enable kvm support. + ''; + default = true; + type = types.bool; + }; + + nixCacheLocation = lib.mkOption { + description = '' + Location of nix cache that is shared between builds + ''; + type = types.path; + }; + + runnerEnvironment = lib.mkOption { + description = '' + Additional environment vars added to the vars file on container runtime + ''; + default = {}; + }; + + runnerVarsFile = lib.mkOption { + description = '' + Location of vars file passed to drone runner + ''; + type = types.path; + }; + }; + + config = lib.mkIf cfg.enable { + virtualisation = { + docker = { + enable = true; # sadly podman is not supported rightnow + }; + + oci-containers = { + backend = "docker"; + containers."drone-exec-runner" = { + image = "debian"; + autoStart = true; + entrypoint = "bash"; + cmd = [ "/bootstrap.sh" ]; + + volumes = [ + "${cfg.runnerVarsFile}:/run/vars" + "${cfg.nixCacheLocation}:/nix" + "${bootstrap}:/bootstrap.sh" + ]; + + environment = cfg.runnerEnvironment; + + extraOptions = lib.mkIf cfg.enableKvm [ "--device=/dev/kvm" ]; + }; + }; + }; + }; +} From 5f6988291c0737ad229aac63c07554e5ca83d536 Mon Sep 17 00:00:00 2001 From: Hendrik Sokolowski Date: Wed, 26 Oct 2022 22:04:48 +0200 Subject: [PATCH 6/7] Fix wording --- modules/docker-ci-runner/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/docker-ci-runner/default.nix b/modules/docker-ci-runner/default.nix index 2a32b8fa..be7ecc47 100644 --- a/modules/docker-ci-runner/default.nix +++ b/modules/docker-ci-runner/default.nix @@ -43,7 +43,7 @@ let in { options.pub-solar.docker-ci-runner = { - enable = lib.mkEnableOption "Enables a systemd service that runs drone-ci-runner"; + enable = lib.mkEnableOption "Enables a docker container running a drone exec runner as unprivileged user."; enableKvm = lib.mkOption { description = '' @@ -88,7 +88,7 @@ in autoStart = true; entrypoint = "bash"; cmd = [ "/bootstrap.sh" ]; - + volumes = [ "${cfg.runnerVarsFile}:/run/vars" "${cfg.nixCacheLocation}:/nix" @@ -96,7 +96,7 @@ in ]; environment = cfg.runnerEnvironment; - + extraOptions = lib.mkIf cfg.enableKvm [ "--device=/dev/kvm" ]; }; }; From 25ad234f2a1336e2d50a6a61165bb32b37756cdd Mon Sep 17 00:00:00 2001 From: Hendrik Sokolowski Date: Sun, 30 Oct 2022 21:37:24 +0100 Subject: [PATCH 7/7] add default for nix store path --- modules/docker-ci-runner/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/docker-ci-runner/default.nix b/modules/docker-ci-runner/default.nix index be7ecc47..11998fd9 100644 --- a/modules/docker-ci-runner/default.nix +++ b/modules/docker-ci-runner/default.nix @@ -57,6 +57,7 @@ in description = '' Location of nix cache that is shared between builds ''; + default = "/var/lib/docker-ci-runner"; type = types.path; };