diff --git a/default.nix b/default.nix index 7b66620..88685a6 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,11 @@ -{ pkgs ? import ./nix {} +let flake = import ./nix/compat.nix; +in +{ pkgs ? import flake.inputs.nixpkgs { } , haskellPackages ? pkgs.haskellPackages }: +let + pkgsWithArion = pkgs.extend flake.overlays.default; +in { - arion = import ./nix/arion.nix { inherit pkgs haskellPackages; }; + inherit (pkgsWithArion) arion; } diff --git a/docs/flake-module.nix b/docs/flake-module.nix new file mode 100644 index 0000000..a442d5d --- /dev/null +++ b/docs/flake-module.nix @@ -0,0 +1,20 @@ +{ + perSystem = { config, pkgs, ... }: + let + doc-options = import ./options.nix { }; + + in + { + packages.doc-options = pkgs.callPackage ./options.nix { }; + + checks.doc-options = pkgs.runCommand "doc-options-check" { } '' + if diff --color -u ${./modules/ROOT/partials/NixOSOptions.adoc} ${config.packages.doc-options}; then + touch $out + else + echo 1>&2 "The doc options have changed and need to be added." + echo 1>&2 "Please run ./update-options in the root of your arion clone." + exit 1 + fi + ''; + }; +} diff --git a/flake.lock b/flake.lock index 4e92b89..79b7879 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,61 @@ { "nodes": { - "nixpkgs": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1601906239, - "narHash": "sha256-P1jBYbYeFswig/0FKbgh+BpVhh9iurD3m0T2ae4gdx8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "c2bb4af48d26ed091e5674394bacbf8d488c7939", + "lastModified": 1669931201, + "narHash": "sha256-UnYFeaLPLj7e4eEt4GJooeJZhaZXyloQZYinwO/CeUw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "995d6bc162c0539998ef6375c2c6b612972dc016", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "hercules-ci", + "ref": "easyOverlay", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1668167720, + "narHash": "sha256-5wDTR6xt9BB3BjgKR+YOjOkZgMyDXKaX79g42sStzDU=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "4fc511d93a55fedf815c1647ad146c26d7a2054e", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1649668654, + "narHash": "sha256-XLLs2mjsnl4Yl9rBpfEwgvm+Tzd+RIta0N7lYdsbxHY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14aa201b658f43546b00153bb2ada7206ba8dd26", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "14aa201b658f43546b00153bb2ada7206ba8dd26", + "type": "github" } }, "root": { "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index b7fb810..ea674e4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,44 +1,91 @@ { description = "Arion - use Docker Compose via Nix"; - outputs = { self, nixpkgs }: - let - lib = import (nixpkgs + "/lib"); - systems = [ - "aarch64-linux" - "x86_64-darwin" - "x86_64-linux" - ]; - arionFromPkgs = pkgs: import ./nix/arion.nix { inherit pkgs; }; - in { - - # The overlay is currently the recommended way to integrate arion, - # because its arion attribute behaves just like Nixpkgs. - overlay = final: prev: { - arion = arionFromPkgs final; - }; - - packages = lib.genAttrs systems (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - arion = arionFromPkgs pkgs; - }); - - # Does not include the eval and build functions like you may expect from Nixpkgs. - defaultPackage = lib.genAttrs systems (system: - self.packages.${system}.arion - ); - - lib = { - eval = import ./src/nix/eval-composition.nix; - build = args@{...}: - let composition = self.lib.eval args; - in composition.config.out.dockerComposeYaml; - }; - - nixosModules.arion = ./nixos-module.nix; - + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/14aa201b658f43546b00153bb2ada7206ba8dd26"; # TODO nixos-unstable + haskell-flake.url = "github:srid/haskell-flake"; + flake-parts.url = "github:hercules-ci/flake-parts/easyOverlay"; # TODO merge + flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; }; + + outputs = inputs@{ self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit self; } ({ config, lib, extendModules, ... }: { + imports = [ + inputs.haskell-flake.flakeModule + inputs.flake-parts.flakeModules.easyOverlay + ./docs/flake-module.nix + ./tests/flake-module.nix + ]; + # FIXME use: systems = inputs.nixpkgs.lib.systems.flakeExposed; + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, final, ... }: + let h = pkgs.haskell.lib.compose; in + { + overlayAttrs = { + inherit (config.packages) arion; + arionTestingFlags = { + dockerSupportsSystemd = false; + }; + }; + packages.default = config.packages.arion; + packages.overlay-test = final.arion; + packages.arion = import ./nix/arion.nix { inherit pkgs; }; + haskellProjects.haskell-package = { + # not autodetected: https://github.com/srid/haskell-flake/issues/49 + packages.arion-compose.root = ./.; + + overrides = + self: super: { + arion-compose = + lib.pipe super.arion-compose [ + (h.addBuildTools [ pkgs.nix ]) + (h.overrideCabal (o: { + src = pkgs.lib.sourceByRegex ./. [ + ".*[.]cabal" + "LICENSE" + "src/?.*" + "README.asciidoc" + "CHANGELOG.md" + ]; + preCheck = '' + export NIX_LOG_DIR=$TMPDIR + export NIX_STATE_DIR=$TMPDIR + export NIX_PATH=nixpkgs=${pkgs.path} + ''; + })) + ]; + }; + }; + devShells.default = config.devShells.haskell-package.overrideAttrs (o: { + nativeBuildInputs = o.nativeBuildInputs or [ ] ++ [ + pkgs.docker-compose + pkgs.nixpkgs-fmt + config.haskellProjects.haskell-package.haskellPackages.releaser + ]; + }); + }; + flake = { + debug = { inherit inputs config lib; }; + + defaultPackage = + lib.mapAttrs + (ps: lib.warn "arion.defaultPackage has been removed in favor of arion.packages.\${system}.default" + ps.default) + config.flake.packages; + + lib = { + eval = import ./src/nix/eval-composition.nix; + build = args@{ ... }: + let composition = self.lib.eval args; + in composition.config.out.dockerComposeYaml; + }; + nixosModules.arion = ./nixos-module.nix; + herculesCI.ciSystems = [ + # "aarch64-darwin" + # "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + }; + }); } diff --git a/nix/ci.nix b/nix/ci.nix deleted file mode 100644 index 1e53108..0000000 --- a/nix/ci.nix +++ /dev/null @@ -1,46 +0,0 @@ -let - sources = import ./sources.nix; - lib = import (sources."nixos-unstable" + "/lib"); - inherit (import (sources."project.nix" + "/lib/dimension.nix") { inherit lib; }) dimension; -in - -dimension "Nixpkgs version" { - "nixos-22_05" = { - nixpkgsSource = "nixos-22.05"; - enableDoc = true; - }; - "nixos-unstable" = { - nixpkgsSource = "nixos-unstable"; - isReferenceNixpkgs = true; # match ./default.nix - enableDoc = true; - }; - } ( - _name: { nixpkgsSource, isReferenceNixpkgs ? false, enableDoc ? true, - dockerSupportsSystemd ? false, nixosHasPodmanDockerSocket ? true }: - - - dimension "System" { - "x86_64-linux" = { isReferenceTarget = isReferenceNixpkgs; }; - "x86_64-darwin" = { enableNixOSTests = false; }; - } ( - system: { isReferenceTarget ? false, enableNixOSTests ? true }: - let - pkgs = import ./. { - inherit system dockerSupportsSystemd nixosHasPodmanDockerSocket; - nixpkgsSrc = sources.${nixpkgsSource}; - }; - in - { - inherit (pkgs) arion; - } // lib.optionalAttrs enableNixOSTests { - inherit (pkgs) tests; - } // lib.optionalAttrs enableDoc { - inherit (pkgs) - # FIXME: nixpkgs antora packaging is broken - # doc - doc-options doc-options-check; - } // lib.optionalAttrs isReferenceTarget { - inherit (pkgs.arion-project.haskellPkgs) arion-compose-checked; - } - ) - ) diff --git a/nix/compat.nix b/nix/compat.nix new file mode 100644 index 0000000..f867cea --- /dev/null +++ b/nix/compat.nix @@ -0,0 +1,10 @@ +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/009399224d5e398d03b22badca40a37ac85412a1.tar.gz"; + sha256 = "sha256:0xcr9fibnapa12ywzcnlf54wrmbqqb96fmmv8043zhsycws7bpqy"; + } + ) + { src = ../.; } +).defaultNix diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index 5cc58ac..0000000 --- a/nix/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ sources ? import ./sources.nix -, nixpkgsName ? "nixos-unstable" # match ./ci.nix isReferenceNixpkgs -, nixpkgsSrc ? sources.${nixpkgsName} -, system ? builtins.currentSystem -, dockerSupportsSystemd ? false -, nixosHasPodmanDockerSocket ? true -, ... -}: - -import nixpkgsSrc ({ - # Makes the config pure as well. See /top-level/impure.nix: - config = { - }; - overlays = [ - (_: _: { - arionTestingFlags = { - inherit dockerSupportsSystemd nixosHasPodmanDockerSocket; - }; - }) - (import ./overlay.nix) - ]; - inherit system; -}) diff --git a/nix/haskell-overlay.nix b/nix/haskell-overlay.nix deleted file mode 100644 index f0c5ccb..0000000 --- a/nix/haskell-overlay.nix +++ /dev/null @@ -1,16 +0,0 @@ -self: super: hself: hsuper: -{ - arion-compose = import ./haskell-arion-compose.nix { pkgs = self; haskellPackages = hself; }; - arion-compose-checked = - let pkg = /* super.haskell.lib.buildStrictly currently broken in nixos-unstable */ hself.arion-compose; - checked = super.haskell.lib.overrideCabal pkg (o: { - postConfigure = ''${o.postConfigure or ""} - if ! ${hsuper.cabal-install}/bin/cabal check; - then - echo 1>&2 ERROR: cabal file is invalid. Above warnings were errors. - exit 1 - fi - ''; - }); - in checked; -} \ No newline at end of file diff --git a/nix/overlay.nix b/nix/overlay.nix deleted file mode 100644 index ecdb6af..0000000 --- a/nix/overlay.nix +++ /dev/null @@ -1,60 +0,0 @@ -self: super: -let - inherit (self.arion-project) haskellPkgs; - inherit (super) lib; - - sources = import ./sources.nix; - - fakeRepo = src: super.runCommand "source" { inherit src; nativeBuildInputs = [super.git]; } '' - cp -r --no-preserve=mode $src $out - git init - cp -r .git $out - ''; - -in -{ - - inherit (import ./.. { pkgs = self; }) arion; - tests = super.callPackage ../tests {}; - - doc-options = import ../docs/options.nix {}; - doc-options-check = self.runCommand "doc-options-check" {} '' - if diff --color -u ${../docs/modules/ROOT/partials/NixOSOptions.adoc} ${self.doc-options}; then - touch $out - else - echo 1>&2 "The doc options have changed and need to be added." - echo 1>&2 "Please run ./update-options in the root of your arion clone." - exit 1 - fi - ''; - doc = self.stdenv.mkDerivation { - name = "arion-documentation"; - nativeBuildInputs = [super.antora]; - src = fakeRepo ../.; - HOME = "."; - buildPhase = "antora antora-playbook"; - installPhase = '' - mkdir $out - mv public/* $out/ - ''; - }; - - arion-project = super.recurseIntoAttrs { - haskellPkgs = super.haskellPackages.extend (import ./haskell-overlay.nix self super); - shell = haskellPkgs.shellFor { - packages = p: [p.arion-compose]; - nativeBuildInputs = [ - haskellPkgs.cabal-install - haskellPkgs.ghcid - haskellPkgs.haskell-language-server - super.docker-compose - self.niv - self.nixpkgs-fmt - self.releaser - ]; - }; - }; - - inherit (import (sources.niv) {}) niv; - releaser = self.haskellPackages.callCabal2nix "releaser" sources.releaser {}; -} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 037ef0c..0000000 --- a/nix/sources.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "fad2a6cbfb2e7cdebb7cb0ad2f5cc91e2c9bc06b", - "sha256": "0mghc1j0rd15spdjx81bayjqr0khc062cs25y5dcfzlxk4ynyc6m", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/fad2a6cbfb2e7cdebb7cb0ad2f5cc91e2c9bc06b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixos-22.05": { - "branch": "nixos-22.05", - "description": "Nix Packages collection", - "homepage": null, - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "a634c8f6c1fbf9b9730e01764999666f3436f10a", - "sha256": "1d40v43x972li5fg7jadxkj341li41mf2cl6vv7xi6j80rkq45q4", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/a634c8f6c1fbf9b9730e01764999666f3436f10a.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixos-unstable": { - "branch": "lib-modules-allow-disable-_modules.args-docs-internal", - "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", - "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "hercules-ci", - "repo": "nixpkgs", - "rev": "14aa201b658f43546b00153bb2ada7206ba8dd26", - "sha256": "0xn43gdn3rfys1d8ni3y6x7vxyc263qsbhfsjwc5x7pcd3dfrcjw", - "type": "tarball", - "url": "https://github.com/hercules-ci/nixpkgs/archive/14aa201b658f43546b00153bb2ada7206ba8dd26.tar.gz", - "url_template": "https://github.com///archive/.tar.gz", - "version": "" - }, - "project.nix": { - "branch": "master", - "description": "A configuration manager for your projects", - "homepage": null, - "owner": "hercules-ci", - "repo": "project.nix", - "rev": "2e598501e7fda6993d2a1a281aa296b26d01e10c", - "sha256": "1rkzpzxpg69px6qwchdlg4xf5irv0snrzk2l6vrs9rsx48gqax9j", - "type": "tarball", - "url": "https://github.com/hercules-ci/project.nix/archive/2e598501e7fda6993d2a1a281aa296b26d01e10c.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "releaser": { - "branch": "master", - "description": "Automation of Haskell package release process.", - "homepage": null, - "owner": "domenkozar", - "repo": "releaser", - "rev": "52a2bb0b2ce0bc15d4e7b11d8761a28d82c0c083", - "sha256": "178lv0a0qxd8six0rm83j7wjwlsad1hysdrk4mb38fagbb8csagb", - "type": "tarball", - "url": "https://github.com/domenkozar/releaser/archive/52a2bb0b2ce0bc15d4e7b11d8761a28d82c0c083.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index b796fff..0000000 --- a/nix/sources.nix +++ /dev/null @@ -1,171 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else ersatz; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/shell.nix b/shell.nix index f6c0ea0..8745f50 100644 --- a/shell.nix +++ b/shell.nix @@ -1 +1 @@ -args@{...}: (import ./nix args).arion-project.shell +(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default diff --git a/tests/arion-test/default.nix b/tests/arion-test/default.nix index 9c7a14a..6035d0d 100644 --- a/tests/arion-test/default.nix +++ b/tests/arion-test/default.nix @@ -1,4 +1,4 @@ -{ usePodman ? false, pkgs, lib, ... }: +{ usePodman ? false, pkgs, lib ? pkgs.lib, ... }: let # To make some prebuilt derivations available in the vm diff --git a/tests/default.nix b/tests/default.nix deleted file mode 100644 index 70012ac..0000000 --- a/tests/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ pkgs ? import ../pkgs.nix, arionTestingFlags ? {} }: -let - inherit (pkgs) nixosTest recurseIntoAttrs arion lib; - - hasEvalModulesType = (lib.evalModules { modules = [ {} ]; })?type; - -in - -recurseIntoAttrs { - - test = nixosTest ./arion-test; - - nixosModuleWithDocker = - lib.optionalAttrs - hasEvalModulesType - ( - import ./nixos-virtualization-arion-test/test.nix pkgs { - virtualisation.arion.backend = "docker"; - } - ); - - nixosModuleWithPodman = - lib.optionalAttrs - (hasEvalModulesType && arionTestingFlags.nixosHasPodmanDockerSocket) - ( - import ./nixos-virtualization-arion-test/test.nix pkgs { - virtualisation.arion.backend = "podman-socket"; - } - ); - - testWithPodman = - if arionTestingFlags.nixosHasPodmanDockerSocket - then nixosTest (import ./arion-test { usePodman = true; inherit pkgs lib; }) - else {}; - - testBuild = arion.build { - - # To be more accurately, you can do - # pkgs = import ../examples/minimal/arion-pkgs.nix; - # but this is quite efficient: - inherit pkgs; - - modules = [ ../examples/minimal/arion-compose.nix ]; - }; - -} diff --git a/tests/flake-module.nix b/tests/flake-module.nix new file mode 100644 index 0000000..bbfdb1d --- /dev/null +++ b/tests/flake-module.nix @@ -0,0 +1,35 @@ +{ + perSystem = { pkgs, final, ... }: + let + inherit (final) nixosTest arion lib; + in + { + checks = lib.optionalAttrs pkgs.stdenv.isLinux { + test = nixosTest ./arion-test; + + nixosModuleWithDocker = + import ./nixos-virtualization-arion-test/test.nix final { + virtualisation.arion.backend = "docker"; + }; + + nixosModuleWithPodman = + import ./nixos-virtualization-arion-test/test.nix final { + virtualisation.arion.backend = "podman-socket"; + }; + + testWithPodman = + nixosTest (import ./arion-test { usePodman = true; pkgs = final; }); + + testBuild = arion.build { + + # To be more accurate, we could do + # pkgs = import ../examples/minimal/arion-pkgs.nix; + # But let's avoid re-evaluating Nixpkgs + pkgs = final; + + modules = [ ../examples/minimal/arion-compose.nix ]; + }; + + }; + }; +} diff --git a/update-options b/update-options index 14a66e9..0e7a02c 100755 --- a/update-options +++ b/update-options @@ -1,9 +1,9 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash +#!nix-shell -i bash -p jq set -eu -o pipefail cd "$(dirname ${BASH_SOURCE[0]})" -doc_options="$(nix-build nix -A doc-options)" +doc_options="$(nix build .#doc-options --json | jq -r .[].outputs.out)" cat "$doc_options" >docs/modules/ROOT/partials/NixOSOptions.adoc