From 2192673f5ababcf34d67f9861510dad5b2f94a08 Mon Sep 17 00:00:00 2001 From: Albert Cervin Date: Thu, 4 Jan 2024 09:10:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20support=20for=20nixpkgs=20up?= =?UTF-8?q?=20to=2023.11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change linter from nix-lint to statix since the former is broken in 23.11 and seems somewhat unmaintained. Fix all lints as well. --- .github/workflows/checks.yml | 6 +-- CHANGELOG.md | 8 ++++ ci/actionlint | 2 + ci/check | 2 + ci/default.nix | 30 +++++++++------ ci/nixfmt | 2 + ci/{nix-lint => nixlint} | 11 ++++-- ci/shellcheck | 3 ++ component.nix | 12 +++--- default.nix | 49 ++++++++++++------------ documentation/default.nix | 2 +- examples/dependencies/child/flake.lock | 32 ++++++++++++---- examples/dependencies/child/flake.nix | 4 +- examples/dependencies/father/project.nix | 2 +- examples/documentation/flake.lock | 42 ++++++++++++++++++-- examples/documentation/flake.nix | 4 +- examples/hello/clients/hello/hello.nix | 4 +- examples/hello/flake.lock | 32 ++++++++++++---- examples/hello/flake.nix | 4 +- flake.lock | 32 ++++++++++++---- flake.nix | 12 +++--- nixpkgs.nix | 1 - shell-commands.nix | 4 +- shells.nix | 12 +++--- target-setup/default.nix | 3 +- test/components.nix | 2 +- 26 files changed, 215 insertions(+), 102 deletions(-) rename ci/{nix-lint => nixlint} (55%) delete mode 100644 nixpkgs.nix diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b5dc3386..c39b8082 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -8,7 +8,7 @@ on: default: true type: boolean - nix-lint: + nixlint: description: "If linting of nix files should run, default true." default: true type: boolean @@ -63,7 +63,7 @@ jobs: lint: name: Lint Nix Expressions 🦕 📝 👀 - if: ${{ inputs.nix-lint }} + if: ${{ inputs.nixlint }} runs-on: ubuntu-latest steps: @@ -75,7 +75,7 @@ jobs: install_url: https://releases.nixos.org/nix/nix-${{ inputs.nix-version }}/install - name: Lint Nix files 🦕 📝 👀 - run: nix run .#checks.nix-lint + run: nix run .#checks.nixlint actionlint: name: Lint Github Actions 🐙 🐱 🎬 diff --git a/CHANGELOG.md b/CHANGELOG.md index e1664f3c..ce316232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Support for nixpkgs up to 23.11 + +### Changed +- The default linter is now statix instead of nix-lint. The name of the nix attribute and + script is also changed from `nix-lint` to `nixlint` to be consistent with other linting + tools. + ### Fixed - Shells were assuming that the `name` attribute always existed on derivations. This is not always true and `pname` can now also be used. diff --git a/ci/actionlint b/ci/actionlint index e1460136..a132c8d5 100644 --- a/ci/actionlint +++ b/ci/actionlint @@ -3,6 +3,8 @@ set -uo pipefail +@preamble@ + # the two ignores are for an older version of the actionlint tool # TODO: check version? diff --git a/ci/check b/ci/check index 5ae8974e..5a39e26a 100644 --- a/ci/check +++ b/ci/check @@ -5,6 +5,8 @@ set -uo pipefail shopt -s nullglob shopt -s extglob +@preamble@ + export NEDRYLAND_CHECK_COLOR=1 emoji_index=0 exit_code=0 diff --git a/ci/default.nix b/ci/default.nix index ed8acbc8..4fde08e8 100644 --- a/ci/default.nix +++ b/ci/default.nix @@ -4,7 +4,7 @@ , mktemp , shellcheck , shfmt -, nix-linter +, statix , bash , gnused , python3 @@ -17,24 +17,30 @@ runCommandLocal "check" mktemp = "${mktemp}/bin/mktemp"; shellcheck = "${shellcheck}/bin/shellcheck"; shfmt = "${shfmt}/bin/shfmt"; - nixLinter = "${nix-linter}/bin/nix-linter"; + nixLinter = "${statix}/bin/statix"; bash = "${bash}/bin/bash"; sed = "${gnused}/bin/sed"; pyflakes = "${python3.pkgs.pyflakes}/bin/pyflakes"; actionlint = "${actionlint}/bin/actionlint"; + preamble = '' + if [[ ",''${NEDRYLAND_NO_USE_CHECK_FILES:-}," =~ ",$(basename "$0")," ]]; then + echo "forcing file list off for tool \"$(basename "$0")\"" + unset NEDRYLAND_CHECK_FILES + fi + ''; } (builtins.foldl' (buildScript: inputScript: - let - outputScript = "${(builtins.placeholder "out")}/bin/${builtins.head (builtins.split "\\\." (builtins.baseNameOf inputScript))}"; - in - '' - ${buildScript} - mkdir -p "$(dirname "${outputScript}")" - substituteAll ${inputScript} ${outputScript} - chmod +x ${outputScript} - '' + let + outputScript = "${(builtins.placeholder "out")}/bin/${builtins.head (builtins.split "\\\." (builtins.baseNameOf inputScript))}"; + in + '' + ${buildScript} + mkdir -p "$(dirname "${outputScript}")" + substituteAll ${inputScript} ${outputScript} + chmod +x ${outputScript} + '' ) "" - [ ./nixfmt ./shellcheck ./nix-lint ./check ./actionlint ] + [ ./nixfmt ./shellcheck ./nixlint ./check ./actionlint ] ) diff --git a/ci/nixfmt b/ci/nixfmt index 2af0cb53..70490a29 100644 --- a/ci/nixfmt +++ b/ci/nixfmt @@ -4,6 +4,8 @@ set -uo pipefail color="auto" +@preamble@ + [ -n "${NEDRYLAND_CHECK_COLOR:-}" ] && color="always" check="--check" diff --git a/ci/nix-lint b/ci/nixlint similarity index 55% rename from ci/nix-lint rename to ci/nixlint index 3fd028fc..a22c468e 100644 --- a/ci/nix-lint +++ b/ci/nixlint @@ -1,16 +1,19 @@ #! @bash@ # shellcheck shell=bash -set -uo pipefail +@preamble@ +set -uo pipefail if [ $# -eq 0 ]; then if [ -z "${NEDRYLAND_CHECK_FILES:-}" ]; then - @nixLinter@ -r . + @nixLinter@ check . exit $? else exitCode=0 - while mapfile -t -n 50 nix_files && ((${#nix_files[@]})); do - if ! @nixLinter@ "${nix_files[@]}"; then + # statix cannot support multiple files + # https://github.com/nerdypepper/statix/issues/69 + while mapfile -t -n 1 nix_files && ((${#nix_files[@]})); do + if ! @nixLinter@ check "${nix_files[@]}"; then exitCode=1; fi done <<< "$(grep ".nix$" < "$NEDRYLAND_CHECK_FILES")" diff --git a/ci/shellcheck b/ci/shellcheck index 03ece541..5f068821 100644 --- a/ci/shellcheck +++ b/ci/shellcheck @@ -2,6 +2,9 @@ # shellcheck shell=bash set -uo pipefail + +@preamble@ + color="auto" [ -n "${NEDRYLAND_CHECK_COLOR:-}" ] && color="always" diff --git a/component.nix b/component.nix index 6360bdf0..4d2036d4 100644 --- a/component.nix +++ b/component.nix @@ -13,16 +13,16 @@ rec { mkComponentInner = attrs@{ name, nedrylandType ? "component", ... }: let component = - (attrs // { + attrs // { inherit name path nedrylandType; } // (pkgs.lib.optionalAttrs (nedrylandType != "component-set" && attrs ? deployment) { # the deploy target is simply the sum of everything # in the deployment set deploy = mkCombinedDeployment "${name}-deploy" attrs.deployment; deployment = attrs.deployment // - (pkgs.linkFarm - "${name}-deployment" - (pkgs.lib.mapAttrsToList (name: path: { inherit name path; }) attrs.deployment)); + (pkgs.linkFarm + "${name}-deployment" + (pkgs.lib.mapAttrsToList (name: path: { inherit name path; }) attrs.deployment)); }) // (pkgs.lib.optionalAttrs (nedrylandType != "component-set" && attrs ? docs && !pkgs.lib.isDerivation attrs.docs) { # the docs target is a symlinkjoin of all sub-derivations docs = @@ -41,7 +41,7 @@ rec { echo '${builtins.toJSON attrsWithResolvedDocDrvs}' > $out/share/doc/${name}/metadata.json ''; }; - })); + }); docsRequirement = (parseConfig { key = "docs"; @@ -98,7 +98,7 @@ rec { if value.isNedrylandComponent or false then [ ({ - accessPath = (path ++ [ name ]); + accessPath = path ++ [ name ]; } // value) ] ++ (recurse (path ++ [ name ]) value) else diff --git a/default.nix b/default.nix index b9e66b69..c264c0f1 100644 --- a/default.nix +++ b/default.nix @@ -1,21 +1,10 @@ let - gitignore = import (builtins.fetchTarball { - url = "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz"; - sha256 = "sha256:07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh"; - }); - - gitIgnoreOverlay = _: prev: (gitignore { - lib = prev.lib // (prev.lib.optionalAttrs (! prev.lib ? inPureEvalMode) { - inPureEvalMode = ! builtins ? currentSystem; - }); - }); - f = { pkgs, skipNixpkgsVersionCheck ? false }: assert pkgs.lib.assertMsg (!skipNixpkgsVersionCheck && pkgs.lib.versionAtLeast (builtins.replaceStrings [ "pre-git" ] [ "" ] (pkgs.lib.version or "0.0.0")) "22.05") "Nedryland supports nixpkgs versions >= 22.05, you have ${pkgs.lib.version or "unknown"}}"; let - pkgs' = pkgs.extend gitIgnoreOverlay; + pkgs' = pkgs; version = "9.0.0"; versionAtLeast = pkgs'.lib.versionAtLeast version; in @@ -90,10 +79,19 @@ let (!(attrs ? name) -> attrs ? pname && attrs ? version) "mkDerivation missing required argument name, alternatively supply pname and version."; let + gitignore = (import (builtins.fetchTarball { + url = "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz"; + sha256 = "sha256:07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh"; + })) { + lib = pkgs'.lib // (pkgs'.lib.optionalAttrs (! pkgs'.lib ? inPureEvalMode) { + inPureEvalMode = ! builtins ? currentSystem; + }); + }; + customerFilter = src: let # IMPORTANT: use a let binding like this to memoize info about the git directories. - srcIgnored = pkgs'.gitignoreFilter src; + srcIgnored = gitignore.gitignoreFilter src; in filter: path: type: @@ -105,7 +103,7 @@ let inherit (attrs) src; filter = customerFilter attrs.src attrs.srcFilter; name = "${attrs.name or attrs.pname}-source"; - } else pkgs'.gitignoreSource attrs.src; + } else gitignore.gitignoreSource attrs.src; in stdenv.mkDerivation ((builtins.removeAttrs attrs [ "stdenv" "srcFilter" "shellCommands" ]) // { @@ -118,18 +116,19 @@ let } // pkgs'.lib.optionalAttrs (attrs.doCheck or true) ( - let checkAttrs = { - # LintPhase for checks that does not require to run the built program - lintPhase = attrs.lintPhase or ''echo "No lintPhase defined, doing nothing"''; - preInstallPhases = attrs.preInstallPhases or [ ] ++ [ "lintPhase" ]; - nativeBuildInputs = attrs.nativeBuildInputs or [ ] ++ attrs.lintInputs or [ ]; - }; + let + checkAttrs = { + # LintPhase for checks that does not require to run the built program + lintPhase = attrs.lintPhase or ''echo "No lintPhase defined, doing nothing"''; + preInstallPhases = attrs.preInstallPhases or [ ] ++ [ "lintPhase" ]; + nativeBuildInputs = attrs.nativeBuildInputs or [ ] ++ attrs.lintInputs or [ ]; + }; in - (checkAttrs // pkgs'.lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && attrs.doCrossCheck or false) { + checkAttrs // pkgs'.lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && attrs.doCrossCheck or false) { crossCheckPhase = attrs.crossCheckPhase or attrs.checkPhase or ''echo "No checkPhase or crossCheckPhase defined (but doCrossCheck is true), doing nothing"''; preInstallPhases = checkAttrs.preInstallPhases ++ [ "crossCheckPhase" ]; nativeBuildInputs = checkAttrs.nativeBuildInputs ++ attrs.checkInputs or [ ]; - }) + } ) // (pkgs'.lib.optionalAttrs (attrs ? src) { src = if pkgs'.lib.isStorePath attrs.src then attrs.src else filteredSrc; @@ -166,7 +165,7 @@ let extFn ( builtins.intersectAttrs args (components // { inherit components; }) // builtins.intersectAttrs args pkgs' - // builtins.intersectAttrs args (let base = (pkgs'.lib.recursiveUpdate initialBase combinedBaseExtensions); in base // { inherit base; }) + // builtins.intersectAttrs args (let base = pkgs'.lib.recursiveUpdate initialBase combinedBaseExtensions; in base // { inherit base; }) ) )) ) @@ -313,7 +312,7 @@ let ) (resolvedComponents // extraTargets); in - (rec { + rec { inherit (appliedAttrs) name; pkgs = pkgs'; @@ -350,7 +349,7 @@ let } // (pkgs'.lib.optionalAttrs (appliedAttrs ? version) - { inherit (appliedAttrs) version; })); + { inherit (appliedAttrs) version; }); override = f; }; diff --git a/documentation/default.nix b/documentation/default.nix index e5a2026e..0f66216c 100644 --- a/documentation/default.nix +++ b/documentation/default.nix @@ -15,7 +15,7 @@ in builtins.mapAttrs (_: f: attrs: { - docfunction = (name: type: (f ({ inherit name type; } // attrs))); + docfunction = name: type: (f ({ inherit name type; } // attrs)); }) rec { mkProjectDocs = diff --git a/examples/dependencies/child/flake.lock b/examples/dependencies/child/flake.lock index cbfebb88..8df03d1b 100644 --- a/examples/dependencies/child/flake.lock +++ b/examples/dependencies/child/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -17,16 +20,16 @@ }, "pkgs": { "locked": { - "lastModified": 1671313200, - "narHash": "sha256-itZTrtHeDJjV696+ur0/TzkTqb5y3Eb57WRLRPK3rwA=", + "lastModified": 1703992652, + "narHash": "sha256-C0o8AUyu8xYgJ36kOxJfXIroy9if/G6aJbNOpA5W0+M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0938d73bb143f4ae037143572f11f4338c7b2d1c", + "rev": "32f63574c85fbc80e4ba1fbb932cde9619bad25e", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "pkgs": "pkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/examples/dependencies/child/flake.nix b/examples/dependencies/child/flake.nix index 73b777fe..33ef7303 100644 --- a/examples/dependencies/child/flake.nix +++ b/examples/dependencies/child/flake.nix @@ -2,8 +2,8 @@ description = "Example project demonstrating project dependencies."; inputs = { - pkgs.url = github:NixOS/nixpkgs/nixos-22.11; - flake-utils.url = github:numtide/flake-utils; + pkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { pkgs, flake-utils, ... }: diff --git a/examples/dependencies/father/project.nix b/examples/dependencies/father/project.nix index 6292565a..0881053b 100644 --- a/examples/dependencies/father/project.nix +++ b/examples/dependencies/father/project.nix @@ -2,7 +2,7 @@ (nedryland { inherit pkgs; }).mkProject { name = "dep-example-father"; - components = {}: { }; + components = _: { }; baseExtensions = [ ./extensions/mkfather.nix diff --git a/examples/documentation/flake.lock b/examples/documentation/flake.lock index 7768b08b..8df03d1b 100644 --- a/examples/documentation/flake.lock +++ b/examples/documentation/flake.lock @@ -1,25 +1,59 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "pkgs": { "locked": { - "lastModified": 1670856834, - "narHash": "sha256-GitzxDZo7385SBoMpHRA9NBAhBh/5TBK8ptpQFAoMYc=", + "lastModified": 1703992652, + "narHash": "sha256-C0o8AUyu8xYgJ36kOxJfXIroy9if/G6aJbNOpA5W0+M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "06278c77b5d162e62df170fec307e83f1812d94b", + "rev": "32f63574c85fbc80e4ba1fbb932cde9619bad25e", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { + "flake-utils": "flake-utils", "pkgs": "pkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/examples/documentation/flake.nix b/examples/documentation/flake.nix index a83b5b14..64f32ac4 100644 --- a/examples/documentation/flake.nix +++ b/examples/documentation/flake.nix @@ -2,8 +2,8 @@ description = "Example project demonstrating documentation capabilities."; inputs = { - pkgs.url = github:NixOS/nixpkgs/nixos-22.11; - flake-utils.url = github:numtide/flake-utils; + pkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { pkgs, flake-utils, ... }: diff --git a/examples/hello/clients/hello/hello.nix b/examples/hello/clients/hello/hello.nix index 025af4e1..2cd182c5 100644 --- a/examples/hello/clients/hello/hello.nix +++ b/examples/hello/clients/hello/hello.nix @@ -5,7 +5,7 @@ base.mkClient rec{ name = "hello"; version = "1.0.0"; - package = ((writeScriptBin name '' + package = (writeScriptBin name '' set -e translation=$(${greeting.lib}/bin/greetinglib $1) echo "Hello in $1 is \"$translation\"" @@ -35,6 +35,6 @@ base.mkClient rec{ ''; }; }; - })); + }); } diff --git a/examples/hello/flake.lock b/examples/hello/flake.lock index 629c674a..8df03d1b 100644 --- a/examples/hello/flake.lock +++ b/examples/hello/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -17,16 +20,16 @@ }, "pkgs": { "locked": { - "lastModified": 1670856834, - "narHash": "sha256-GitzxDZo7385SBoMpHRA9NBAhBh/5TBK8ptpQFAoMYc=", + "lastModified": 1703992652, + "narHash": "sha256-C0o8AUyu8xYgJ36kOxJfXIroy9if/G6aJbNOpA5W0+M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "06278c77b5d162e62df170fec307e83f1812d94b", + "rev": "32f63574c85fbc80e4ba1fbb932cde9619bad25e", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.11", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "pkgs": "pkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/examples/hello/flake.nix b/examples/hello/flake.nix index c39ea524..e4753c0a 100644 --- a/examples/hello/flake.nix +++ b/examples/hello/flake.nix @@ -2,8 +2,8 @@ description = "Example project demonstrating simple components."; inputs = { - pkgs.url = github:NixOS/nixpkgs/nixos-22.11; - flake-utils.url = github:numtide/flake-utils; + pkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; }; outputs = { pkgs, flake-utils, ... }: diff --git a/flake.lock b/flake.lock index f1480d12..d562aee4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -17,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1672580127, - "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "lastModified": 1704295289, + "narHash": "sha256-9WZDRfpMqCYL6g/HNWVvXF0hxdaAgwgIGeLYiOhmes8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0874168639713f547c05947c76124f78441ea46c", + "rev": "b0b2c5445c64191fd8d0b31f2b1a34e45a64547d", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.05", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 16eab0c8..3f16d3be 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,14 @@ { description = "Nedryland is a collection of utilities and a build system for declaring, building and deploying microservice solutions."; - inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.05; - inputs.flake-utils.url = github:numtide/flake-utils; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages."${system}"; - internalNedryland = (import ./default.nix { inherit pkgs; }); + internalNedryland = import ./default.nix { inherit pkgs; }; in { lib = import ./.; @@ -23,7 +23,7 @@ apps = { checks = rec { type = "app"; - program = all.program; + inherit (all) program; nixfmt = { type = "app"; @@ -33,9 +33,9 @@ type = "app"; program = "${internalNedryland.checks}/bin/shellcheck"; }; - nix-lint = { + nixlint = { type = "app"; - program = "${internalNedryland.checks}/bin/nix-lint"; + program = "${internalNedryland.checks}/bin/nixlint"; }; all = { type = "app"; diff --git a/nixpkgs.nix b/nixpkgs.nix deleted file mode 100644 index 7cbed45e..00000000 --- a/nixpkgs.nix +++ /dev/null @@ -1 +0,0 @@ -(builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/925ae0dee63cf2c59533a6258340812e5643428a.tar.gz) diff --git a/shell-commands.nix b/shell-commands.nix index 2e4e7714..509bd532 100644 --- a/shell-commands.nix +++ b/shell-commands.nix @@ -48,8 +48,8 @@ let ${shellCommandHelpText (builtins.mapAttrs (_: value: { - description = (if builtins.isAttrs value then value.description or "" else ""); - args = (if builtins.isAttrs value then value.args or "" else ""); + description = if builtins.isAttrs value then value.description or "" else ""; + args = if builtins.isAttrs value then value.args or "" else ""; } ) (lib.filterAttrs (_: value: diff --git a/shells.nix b/shells.nix index a1386e2d..19cf8f57 100644 --- a/shells.nix +++ b/shells.nix @@ -51,9 +51,9 @@ in # # Priority of nativeBuildInputs then becomes: # 1. nativeBuildInputs - # 2. checkInputs/installCheckInputs - # 3. shellInputs - # 4. shellCommands + # 2. shellInputs + # 3. shellCommands + # 4. nativeCheckInputs/checkInputs/installCheckInputs nativeBuildInputs = oldAttrs.nativeBuildInputs or [ ] ++ oldAttrs.passthru.shellInputs or [ ] ++ oldAttrs.shellInputs or [ ] @@ -79,7 +79,7 @@ in fi # This is for `nix develop` and flakes. - if [[ "$componentDir" == /nix/store/* ]]; then + if [[ "$componentDir" =~ ^/nix/store/.*$ ]]; then git_root=$(${git}/bin/git rev-parse --show-toplevel) target_relative="$(echo "$componentDir" | cut -d/ -f 5-)" componentDir="$git_root/$target_relative" @@ -123,7 +123,7 @@ in defaultShell.overrideAttrs (_: { passthru = componentShellsAndSubComponents // lib.optionalAttrs (component ? docs) - ({ + { docs = mkShell { shellHook = '' echo -e '\x1b[31mInvalid shell "docs"!\x1b[0m' @@ -138,7 +138,7 @@ in } (pth ++ [ "docs" ]); }; - }); + }; }) ) ) diff --git a/target-setup/default.nix b/target-setup/default.nix index 38352db2..4abe9ceb 100644 --- a/target-setup/default.nix +++ b/target-setup/default.nix @@ -14,11 +14,12 @@ let key = "components"; structure = pkgs.lib.mapAttrs (_: _: null) (variableQueries // variables); }); + depsAttr = if pkgs.lib.versionOlder pkgs.lib.version "23.05pre-git" then "deps" else "propagatedBuildInputs"; in pkgs.makeSetupHook { name = "target-setup-${builtins.replaceStrings [ " " ] [ "-" ] name}"; - deps = [ pkgs.envsubst pkgs.tree ]; + "${depsAttr}" = [ pkgs.envsubst pkgs.tree ]; substitutions = { inherit typeName showTemplate initCommands; envsubst = "${pkgs.envsubst}/bin/envsubst"; diff --git a/test/components.nix b/test/components.nix index 9b6b775d..0ed1df61 100644 --- a/test/components.nix +++ b/test/components.nix @@ -71,7 +71,7 @@ assertMsg: assert assertMsg (removeAccessPath (componentFns.collectComponentsRecursive project1) - == (with project1; [ component1 component2 ])) + == (with project1; [ component1 component2 ])) "collectComponentsRecursive did not collect!"; assert assertMsg