From 67df2519298546b56d05ac7a12e7517eb307ff1c Mon Sep 17 00:00:00 2001 From: David Arnold Date: Thu, 24 Jun 2021 14:24:10 -0500 Subject: [PATCH] ref: add proper downstream testing --- .github/workflows/check.yml | 4 +- .gitmodules | 3 + examples/classicalDevos/devshell.toml | 5 - examples/classicalDevos/flake.nix | 117 -------------- examples/classicalDevos/hosts/NixOS.nix | 12 -- .../hosts/com/example/myhost/default.nix | 12 -- examples/classicalDevos/lib/default.nix | 2 - examples/classicalDevos/modules/a-module.nix | 1 - .../classicalDevos/modules/customBuilds.nix | 26 --- .../overlays/overlays-order.nix | 3 - .../classicalDevos/overlays/overrides.nix | 28 ---- examples/classicalDevos/pkgs/default.nix | 1 - examples/classicalDevos/pkgs/flake.lock | 25 --- examples/classicalDevos/pkgs/flake.nix | 52 ------ .../profiles/cachix/default.nix | 11 -- .../profiles/cachix/nix-community.nix | 10 -- .../classicalDevos/profiles/cachix/nrdxp.nix | 10 -- .../classicalDevos/profiles/core/default.nix | 148 ------------------ .../profiles/core/starship.toml | 95 ----------- .../users/modules/my-module.nix | 1 - .../classicalDevos/users/nixos/default.nix | 10 -- .../users/profiles/direnv/default.nix | 6 - .../users/profiles/git/default.nix | 45 ------ .../classicalDevos/users/root/default.nix | 5 - examples/downstream | 1 + shell.nix | 51 +++++- 26 files changed, 52 insertions(+), 632 deletions(-) create mode 100644 .gitmodules delete mode 100644 examples/classicalDevos/devshell.toml delete mode 100644 examples/classicalDevos/flake.nix delete mode 100644 examples/classicalDevos/hosts/NixOS.nix delete mode 100644 examples/classicalDevos/hosts/com/example/myhost/default.nix delete mode 100644 examples/classicalDevos/lib/default.nix delete mode 100644 examples/classicalDevos/modules/a-module.nix delete mode 100644 examples/classicalDevos/modules/customBuilds.nix delete mode 100644 examples/classicalDevos/overlays/overlays-order.nix delete mode 100644 examples/classicalDevos/overlays/overrides.nix delete mode 100644 examples/classicalDevos/pkgs/default.nix delete mode 100644 examples/classicalDevos/pkgs/flake.lock delete mode 100644 examples/classicalDevos/pkgs/flake.nix delete mode 100644 examples/classicalDevos/profiles/cachix/default.nix delete mode 100644 examples/classicalDevos/profiles/cachix/nix-community.nix delete mode 100644 examples/classicalDevos/profiles/cachix/nrdxp.nix delete mode 100644 examples/classicalDevos/profiles/core/default.nix delete mode 100644 examples/classicalDevos/profiles/core/starship.toml delete mode 100644 examples/classicalDevos/users/modules/my-module.nix delete mode 100644 examples/classicalDevos/users/nixos/default.nix delete mode 100644 examples/classicalDevos/users/profiles/direnv/default.nix delete mode 100644 examples/classicalDevos/users/profiles/git/default.nix delete mode 100644 examples/classicalDevos/users/root/default.nix create mode 160000 examples/downstream diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 579d3de..0f5ad63 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -12,6 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.3.4 + with: + submodules: true - uses: cachix/install-nix-action@v13 with: install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210415_76980a1/install @@ -25,5 +27,5 @@ jobs: - run: nix develop --command evalnix # Check /examples/* - - run: nix develop --command check-classicalDevos + - run: nix develop --command check-downstream - run: nix develop --command check-groupByConfig diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b4c56b7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "examples/downstream"] + path = examples/downstream + url = git@github.com:divnix/devos.git diff --git a/examples/classicalDevos/devshell.toml b/examples/classicalDevos/devshell.toml deleted file mode 100644 index 2deae10..0000000 --- a/examples/classicalDevos/devshell.toml +++ /dev/null @@ -1,5 +0,0 @@ -[devshell] - -packages = [ - "mdbook", -] diff --git a/examples/classicalDevos/flake.nix b/examples/classicalDevos/flake.nix deleted file mode 100644 index 49e025b..0000000 --- a/examples/classicalDevos/flake.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ - description = "A DevOS example. And also a digga test bed."; - - inputs = - { - nixos.url = "nixpkgs/release-21.05"; - latest.url = "nixpkgs"; - digga = { - url = "path:../../"; - inputs.nixpkgs.follows = "nixos"; - }; - - darwin.url = "github:LnL7/nix-darwin"; - darwin.inputs.nixpkgs.follows = "latest"; - home.url = "github:nix-community/home-manager"; - home.inputs.nixpkgs.follows = "nixos"; - agenix.url = "github:ryantm/agenix"; - agenix.inputs.nixpkgs.follows = "latest"; - nixos-hardware.url = "github:nixos/nixos-hardware"; - - pkgs.url = "path:./pkgs"; - pkgs.inputs.nixpkgs.follows = "nixos"; - }; - - outputs = - { self - , pkgs - , digga - , nixos - , home - , nixos-hardware - , agenix - , ... - } @ inputs: - digga.lib.mkFlake { - inherit self inputs; - - channelsConfig = { allowUnfree = true; }; - - channels = { - nixos = { - imports = [ (digga.lib.importers.overlays ./overlays) ]; - overlays = [ - # mimicking an external overlay - (final: prev: { i-do-exists-before-local-overlays-accessor-me = prev.hello; }) - ./pkgs/default.nix - pkgs.overlay # for `srcs` - agenix.overlay - ]; - }; - latest = { }; - }; - - lib = import ./lib { lib = digga.lib // nixos.lib; }; - - sharedOverlays = [ - (final: prev: { - __dontExport = true; - lib = prev.lib.extend (lfinal: lprev: { - our = self.lib; - }); - }) - ]; - - nixos = { - hostDefaults = { - system = "x86_64-linux"; - channelName = "nixos"; - imports = [ (digga.lib.importers.modules ./modules) ]; - externalModules = [ - { lib.our = self.lib; } - home.nixosModules.home-manager - agenix.nixosModules.age - ]; - }; - - imports = [ (digga.lib.importers.hosts ./hosts) ]; - hosts = { - /* set host specific properties here */ - NixOS = { }; - }; - importables = rec { - profiles = digga.lib.importers.rakeLeaves ./profiles // { - users = digga.lib.importers.rakeLeaves ./users; - }; - suites = with profiles; rec { - base = [ core users.nixos users.root ]; - }; - }; - }; - - home = { - imports = [ (digga.lib.importers.modules ./users/modules) ]; - externalModules = [ ]; - importables = rec { - profiles = digga.lib.importers.rakeLeaves ./users/profiles; - suites = with profiles; rec { - base = [ direnv git ]; - }; - }; - }; - - devshell.externalModules = { pkgs, ... }: { - packages = [ pkgs.agenix ]; - }; - - homeConfigurations = digga.lib.mkHomeConfigurations self.nixosConfigurations; - - deploy.nodes = digga.lib.mkDeployNodes self.nixosConfigurations { }; - - defaultTemplate = self.templates.flk; - templates.flk.path = ./.; - templates.flk.description = "flk template"; - - } - ; -} diff --git a/examples/classicalDevos/hosts/NixOS.nix b/examples/classicalDevos/hosts/NixOS.nix deleted file mode 100644 index 3b08411..0000000 --- a/examples/classicalDevos/hosts/NixOS.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ suites, ... }: -{ - ### root password is empty by default ### - imports = suites.base; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.networkmanager.enable = true; - - fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; -} diff --git a/examples/classicalDevos/hosts/com/example/myhost/default.nix b/examples/classicalDevos/hosts/com/example/myhost/default.nix deleted file mode 100644 index 3b08411..0000000 --- a/examples/classicalDevos/hosts/com/example/myhost/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ suites, ... }: -{ - ### root password is empty by default ### - imports = suites.base; - - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.networkmanager.enable = true; - - fileSystems."/" = { device = "/dev/disk/by-label/nixos"; }; -} diff --git a/examples/classicalDevos/lib/default.nix b/examples/classicalDevos/lib/default.nix deleted file mode 100644 index 2356e1f..0000000 --- a/examples/classicalDevos/lib/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ lib }: -lib.makeExtensible (self: { }) diff --git a/examples/classicalDevos/modules/a-module.nix b/examples/classicalDevos/modules/a-module.nix deleted file mode 100644 index c915eb0..0000000 --- a/examples/classicalDevos/modules/a-module.nix +++ /dev/null @@ -1 +0,0 @@ -{ ... }: { } diff --git a/examples/classicalDevos/modules/customBuilds.nix b/examples/classicalDevos/modules/customBuilds.nix deleted file mode 100644 index cbaefe3..0000000 --- a/examples/classicalDevos/modules/customBuilds.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ lib, pkgs, self, config, modules, channel, ... }: -{ - system.build = { - iso = (config.lib.digga.mkBuild - (config.lib.digga.modules.isoConfig { - inherit self; - fullHostConfig = config; - }) - ).config.system.build.isoImage; - - homes = (config.lib.digga.mkBuild - ({ config, ... }: { - home-manager.useUserPackages = lib.mkForce false; - home-manager.sharedModules = [ - { - home.sessionVariables = { - inherit (config.environment.sessionVariables) NIX_PATH; - }; - xdg.configFile."nix/registry.json".text = - config.environment.etc."nix/registry.json".text; - } - ]; - }) - ).config.home-manager.users; - }; -} diff --git a/examples/classicalDevos/overlays/overlays-order.nix b/examples/classicalDevos/overlays/overlays-order.nix deleted file mode 100644 index d38aa95..0000000 --- a/examples/classicalDevos/overlays/overlays-order.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - i-was-accessed-without-error = prev.i-do-exists-before-local-overlays-accessor-me; -} diff --git a/examples/classicalDevos/overlays/overrides.nix b/examples/classicalDevos/overlays/overrides.nix deleted file mode 100644 index 59516b3..0000000 --- a/examples/classicalDevos/overlays/overrides.nix +++ /dev/null @@ -1,28 +0,0 @@ -channels: final: prev: { - - __dontExport = true; # overrides clutter up actual creations - - inherit (channels.latest) - cachix - dhall - discord - element-desktop - manix - nixpkgs-fmt - qutebrowser - signal-desktop - starship; - - - haskellPackages = prev.haskellPackages.override { - overrides = hfinal: hprev: - let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; - in - { - # same for haskell packages, matching ghc versions - inherit (channels.latest.haskell.packages."ghc${version}") - haskell-language-server; - }; - }; - -} diff --git a/examples/classicalDevos/pkgs/default.nix b/examples/classicalDevos/pkgs/default.nix deleted file mode 100644 index ce16870..0000000 --- a/examples/classicalDevos/pkgs/default.nix +++ /dev/null @@ -1 +0,0 @@ -final: prev: { } diff --git a/examples/classicalDevos/pkgs/flake.lock b/examples/classicalDevos/pkgs/flake.lock deleted file mode 100644 index ef3f5a9..0000000 --- a/examples/classicalDevos/pkgs/flake.lock +++ /dev/null @@ -1,25 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1615926763, - "narHash": "sha256-yeq8A3EPNuQVlsxlEQrIRsklfJwJK0Us6jtcG/u8wNs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "b702a56d417647de4090ac56c0f18bdc7e646610", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/examples/classicalDevos/pkgs/flake.nix b/examples/classicalDevos/pkgs/flake.nix deleted file mode 100644 index 1b6cc0a..0000000 --- a/examples/classicalDevos/pkgs/flake.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ - description = "Package Sources"; - - inputs = { }; - - outputs = { self, nixpkgs, ... }: { - overlay = final: prev: { - inherit (self) srcs; - }; - - srcs = - let - inherit (nixpkgs) lib; - - mkVersion = name: input: - let - inputs = (builtins.fromJSON - (builtins.readFile ./flake.lock)).nodes; - - ref = - if lib.hasAttrByPath [ name "original" "ref" ] inputs - then inputs.${name}.original.ref - else ""; - - version = - let version' = builtins.match - "[[:alpha:]]*[-._]?([0-9]+(\.[0-9]+)*)+" - ref; - in - if lib.isList version' - then lib.head version' - else if input ? lastModifiedDate && input ? shortRev - then "${lib.substring 0 8 input.lastModifiedDate}_${input.shortRev}" - else null; - in - version; - in - lib.mapAttrs - (pname: input: - let - version = mkVersion pname input; - in - input // { inherit pname; } - // lib.optionalAttrs (! isNull version) - { - inherit version; - } - ) - (lib.filterAttrs (n: _: n != "nixpkgs") - self.inputs); - }; -} diff --git a/examples/classicalDevos/profiles/cachix/default.nix b/examples/classicalDevos/profiles/cachix/default.nix deleted file mode 100644 index d88a3f7..0000000 --- a/examples/classicalDevos/profiles/cachix/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, lib, ... }: -let - folder = ./.; - toImport = name: value: folder + ("/" + name); - filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key && key != "default.nix"; - imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); -in -{ - inherit imports; - nix.binaryCaches = [ "https://cache.nixos.org/" ]; -} diff --git a/examples/classicalDevos/profiles/cachix/nix-community.nix b/examples/classicalDevos/profiles/cachix/nix-community.nix deleted file mode 100644 index 7e4be28..0000000 --- a/examples/classicalDevos/profiles/cachix/nix-community.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - nix = { - binaryCaches = [ - "https://nix-community.cachix.org" - ]; - binaryCachePublicKeys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; -} diff --git a/examples/classicalDevos/profiles/cachix/nrdxp.nix b/examples/classicalDevos/profiles/cachix/nrdxp.nix deleted file mode 100644 index bb3b4a5..0000000 --- a/examples/classicalDevos/profiles/cachix/nrdxp.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - nix = { - binaryCaches = [ - "https://nrdxp.cachix.org" - ]; - binaryCachePublicKeys = [ - "nrdxp.cachix.org-1:Fc5PSqY2Jm1TrWfm88l6cvGWwz3s93c6IOifQWnhNW4=" - ]; - }; -} diff --git a/examples/classicalDevos/profiles/core/default.nix b/examples/classicalDevos/profiles/core/default.nix deleted file mode 100644 index 41b5136..0000000 --- a/examples/classicalDevos/profiles/core/default.nix +++ /dev/null @@ -1,148 +0,0 @@ -{ self, config, lib, pkgs, ... }: -let inherit (lib) fileContents; -in -{ - imports = [ ../cachix ]; - - nix.systemFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; - - environment = { - - systemPackages = with pkgs; [ - binutils - coreutils - curl - direnv - dnsutils - dosfstools - fd - git - gotop - gptfdisk - iputils - jq - manix - moreutils - nix-index - nmap - ripgrep - skim - tealdeer - usbutils - utillinux - whois - ]; - - shellInit = '' - export STARSHIP_CONFIG=${ - pkgs.writeText "starship.toml" - (fileContents ./starship.toml) - } - ''; - - shellAliases = - let ifSudo = lib.mkIf config.security.sudo.enable; - in - { - # quick cd - ".." = "cd .."; - "..." = "cd ../.."; - "...." = "cd ../../.."; - "....." = "cd ../../../.."; - - # git - g = "git"; - - # grep - grep = "rg"; - gi = "grep -i"; - - # internet ip - myip = "dig +short myip.opendns.com @208.67.222.222 2>&1"; - - # nix - n = "nix"; - np = "n profile"; - ni = "np install"; - nr = "np remove"; - ns = "n search --no-update-lock-file"; - nf = "n flake"; - nepl = "n repl ''"; - srch = "ns nixos"; - orch = "ns override"; - nrb = ifSudo "sudo nixos-rebuild"; - mn = '' - manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix - ''; - - # fix nixos-option - nixos-option = "nixos-option -I nixpkgs=${self}/lib/compat"; - - # sudo - s = ifSudo "sudo -E "; - si = ifSudo "sudo -i"; - se = ifSudo "sudoedit"; - - # top - top = "gotop"; - - # systemd - ctl = "systemctl"; - stl = ifSudo "s systemctl"; - utl = "systemctl --user"; - ut = "systemctl --user start"; - un = "systemctl --user stop"; - up = ifSudo "s systemctl start"; - dn = ifSudo "s systemctl stop"; - jtl = "journalctl"; - - }; - }; - - fonts = { - fonts = with pkgs; [ powerline-fonts dejavu_fonts ]; - - fontconfig.defaultFonts = { - - monospace = [ "DejaVu Sans Mono for Powerline" ]; - - sansSerif = [ "DejaVu Sans" ]; - - }; - }; - - nix = { - - autoOptimiseStore = true; - - gc.automatic = true; - - optimise.automatic = true; - - useSandbox = true; - - allowedUsers = [ "@wheel" ]; - - trustedUsers = [ "root" "@wheel" ]; - - extraOptions = '' - min-free = 536870912 - keep-outputs = true - keep-derivations = true - fallback = true - ''; - - }; - - programs.bash = { - promptInit = '' - eval "$(${pkgs.starship}/bin/starship init bash)" - ''; - interactiveShellInit = '' - eval "$(${pkgs.direnv}/bin/direnv hook bash)" - ''; - }; - - services.earlyoom.enable = true; - -} diff --git a/examples/classicalDevos/profiles/core/starship.toml b/examples/classicalDevos/profiles/core/starship.toml deleted file mode 100644 index 6ed366b..0000000 --- a/examples/classicalDevos/profiles/core/starship.toml +++ /dev/null @@ -1,95 +0,0 @@ -[aws] -symbol = " " - -[character] -success_symbol = "[❯](bold purple)" -vicmd_symbol = "[❮](bold purple)" - -[battery] -full_symbol = "" -charging_symbol = "" -discharging_symbol = "" - -[conda] -symbol = " " - -[directory] -style = "cyan" -read_only = " 🔒" - -[docker] -symbol = " " - -[elixir] -symbol = " " - -[elm] -symbol = " " - -[git_branch] -format = "[$symbol$branch]($style) " -symbol = " " -style = "bold dimmed white" - -[git_status] -format = '([「$all_status$ahead_behind」]($style) )' -conflicted = "⚠️" -ahead = "⟫${count} " -behind = "⟪${count}" -diverged = "🔀 " -untracked = "📁 " -stashed = "↪ " -modified = "𝚫 " -staged = "✔ " -renamed = "⇆ " -deleted = "✘ " -style = "bold bright-white" - -[golang] -symbol = " " - -[haskell] -symbol = " " - -[hg_branch] -symbol = " " - -[java] -symbol = " " - -[julia] -symbol = " " - -[memory_usage] -symbol = " " -disabled = false - -[nim] -symbol = " " - -[nix_shell] -format = '[$symbol$state]($style) ' -symbol = " " -pure_msg = "λ" -impure_msg = "⎔" - -[nodejs] -symbol = " " - -[package] -symbol = " " - -[php] -symbol = " " - -[python] -symbol = " " - -[ruby] -symbol = " " - -[rust] -symbol = " " - -[status] -disabled = false diff --git a/examples/classicalDevos/users/modules/my-module.nix b/examples/classicalDevos/users/modules/my-module.nix deleted file mode 100644 index c915eb0..0000000 --- a/examples/classicalDevos/users/modules/my-module.nix +++ /dev/null @@ -1 +0,0 @@ -{ ... }: { } diff --git a/examples/classicalDevos/users/nixos/default.nix b/examples/classicalDevos/users/nixos/default.nix deleted file mode 100644 index d0f85ef..0000000 --- a/examples/classicalDevos/users/nixos/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: -{ - users.users.nixos = { - uid = 1000; - password = "nixos"; - description = "default"; - isNormalUser = true; - extraGroups = [ "wheel" ]; - }; -} diff --git a/examples/classicalDevos/users/profiles/direnv/default.nix b/examples/classicalDevos/users/profiles/direnv/default.nix deleted file mode 100644 index 173a9c5..0000000 --- a/examples/classicalDevos/users/profiles/direnv/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - programs.direnv = { - enable = true; - enableNixDirenvIntegration = true; - }; -} diff --git a/examples/classicalDevos/users/profiles/git/default.nix b/examples/classicalDevos/users/profiles/git/default.nix deleted file mode 100644 index 4c9637e..0000000 --- a/examples/classicalDevos/users/profiles/git/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ - programs.git = { - enable = true; - - extraConfig = { - pull.rebase = false; - }; - - aliases = { - a = "add -p"; - co = "checkout"; - cob = "checkout -b"; - f = "fetch -p"; - c = "commit"; - p = "push"; - ba = "branch -a"; - bd = "branch -d"; - bD = "branch -D"; - d = "diff"; - dc = "diff --cached"; - ds = "diff --staged"; - r = "restore"; - rs = "restore --staged"; - st = "status -sb"; - - # reset - soft = "reset --soft"; - hard = "reset --hard"; - s1ft = "soft HEAD~1"; - h1rd = "hard HEAD~1"; - - # logging - lg = - "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"; - plog = - "log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'"; - tlog = - "log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative"; - rank = "shortlog -sn --no-merges"; - - # delete merged branches - bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"; - }; - }; -} diff --git a/examples/classicalDevos/users/root/default.nix b/examples/classicalDevos/users/root/default.nix deleted file mode 100644 index f38c739..0000000 --- a/examples/classicalDevos/users/root/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: -# recommend using `hashedPassword` -{ - users.users.root.password = ""; -} diff --git a/examples/downstream b/examples/downstream new file mode 160000 index 0000000..2a808af --- /dev/null +++ b/examples/downstream @@ -0,0 +1 @@ +Subproject commit 2a808af8b5efa56a84fb0cde490315eeb43f4693 diff --git a/shell.nix b/shell.nix index bf309f9..c4f3b94 100644 --- a/shell.nix +++ b/shell.nix @@ -12,11 +12,50 @@ let help = "Checks ${name} example"; command = '' set -e + + diggaurl= + lockfile_updated=1 + lockfile_present=1 + + cleanup() { + if is $lockfile_present; then + git checkout -- flake.lock + elif is $lockfile_updated; then + git rm -f flake.lock + fi + # ensure: restore input + [ -z $diggaurl ] || sed -i "s|\"path:../../\"|$diggaurl|g" flake.nix + } + + digga_fixture() { + # ensure: replace input + diggaurl=$({ grep -o '"github:divnix/digga.*"' flake.nix || true; }) + sed -i 's|"github:divnix/digga/.*"|"path:../../"|g' flake.nix + } + + trap_err() { + local ret=$? + cleanup + echo -e \ + "\033[1m\033[31m""exit $ret: \033[0m\033[1m""command [$BASH_COMMAND] failed""\033[0m" + } + + is () { [ "$1" -eq "0" ]; } + + trap 'trap_err' ERR + + # -------------------------------------------------------------------------------- + cd $DEVSHELL_ROOT/examples/${name} - ${patchedNixUnstable}/bin/nix flake lock --update-input digga || git rm -f flake.lock - ${patchedNixUnstable}/bin/nix flake show || git rm -f flake.lock - ${patchedNixUnstable}/bin/nix flake check || git rm -f flake.lock - git rm -f flake.lock + + digga_fixture + + test -f flake.lock && lockfile_present=$? || true + ${patchedNixUnstable}/bin/nix flake lock --update-input digga; lockfile_updated=$?; + ${patchedNixUnstable}/bin/nix flake show + ${patchedNixUnstable}/bin/nix flake check + + cleanup ''; }; @@ -56,9 +95,9 @@ devshell.mkShell { command = "fd --extension nix --exec nix-instantiate --parse --quiet {} >/dev/null"; } - (test "classicalDevos") + (test "downstream") (test "groupByConfig") - (test "all" // { command = "check-classicalDevos && groupByConfig"; }) + (test "all" // { command = "check-downstream && groupByConfig"; }) ]; }