From 28bf335bfc5d90be0b183aa8d482c52baa343871 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sat, 27 Apr 2024 16:07:43 +0300 Subject: [PATCH] refactor(flake): - update inputs - use flake-parts - set nixfmt-rfc-style as the default formatter --- action.nix | 444 +++++++++++++++++++++++++++-------------------------- flake.lock | 221 +++++++++++++++++++++++++- flake.nix | 102 +++++++++--- 3 files changed, 523 insertions(+), 244 deletions(-) diff --git a/action.nix b/action.nix index bd28d46c..579ca5aa 100644 --- a/action.nix +++ b/action.nix @@ -1,31 +1,32 @@ { target, lib }: let - specific = { - cache = { - name = "Cache"; - description = "Restore and save"; - actions = "restoring and saving"; - main = "dist/restore/index.js"; - post = - '' + specific = + { + cache = { + name = "Cache"; + description = "Restore and save"; + actions = "restoring and saving"; + main = "dist/restore/index.js"; + post = '' post: "dist/save/index.js" post-if: "success() || github.event.inputs.save-always"''; - }; - save = { - name = "Save"; - description = "Save"; - actions = "saving"; - main = "../dist/save-only/index.js"; - post = ""; - }; - restore = { - name = "Restore"; - description = "Restore"; - actions = "restoring"; - main = "../dist/restore-only/index.js"; - post = ""; - }; - }.${target}; + }; + save = { + name = "Save"; + description = "Save"; + actions = "saving"; + main = "../dist/save-only/index.js"; + post = ""; + }; + restore = { + name = "Restore"; + description = "Restore"; + actions = "restoring"; + main = "../dist/restore-only/index.js"; + post = ""; + }; + } + .${target}; q = txt: "`${txt}`"; whenListOf = "When a newline-separated non-empty list of non-empty"; @@ -35,10 +36,12 @@ let pathsWhen = ''${whenListOf} path patterns (see [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns), the action appends it to default paths and uses the resulting list for ${specific.actions} caches.''; pathsOtherwise = ''Otherwise, the action uses default paths for ${specific.actions} caches.''; - effectOnlyOn = platform: ''Can have an effect only when the action runs on a ${q platform} runner.''; + effectOnlyOn = + platform: ''Can have an effect only when the action runs on a ${q platform} runner.''; linux = "Linux"; macos = "macOS"; - effectOnlyWhen = conditions: "Can have an effect only when ${lib.concatMapStringsSep ", " q conditions}."; + effectOnlyWhen = + conditions: "Can have an effect only when ${lib.concatMapStringsSep ", " q conditions}."; noEffectOtherwise = ''Otherwise, this input has no effect.''; @@ -54,199 +57,208 @@ let hit-first-match = "hit-first-match"; in '' - name: "${specific.name} Nix store" - description: "${specific.description} Nix store using GitHub Actions cache to speed up workflows." - author: "GitHub" - inputs: - ${primary-key}: - description: | - - When a non-empty string, the action uses this key for ${specific.actions} a cache. - - Otherwise, the action fails. - required: true - - ${ - if target == "cache" || target == "restore" then + name: "${specific.name} Nix store" + description: "${specific.description} Nix store using GitHub Actions cache to speed up workflows." + author: "GitHub" + inputs: + ${primary-key}: + description: | + - When a non-empty string, the action uses this key for ${specific.actions} a cache. + - Otherwise, the action fails. + required: true + + ${ + if target == "cache" || target == "restore" then + '' + ${restore-prefixes-first-match}: + description: | + - ${whenListOf} key prefixes, when there's a miss on the ${q primary-key}, + the action searches in this list for the first prefix for which there exists a cache + with a matching key and the action tries to restore that cache. + - ${noEffectOtherwise} + default: "" + restore-prefixes-all-matches: + description: | + - ${whenListOf} key prefixes, the action tries to restore + all caches whose keys match these prefixes. + - Tries caches across all refs to make use of caches created + on the current, base, and default branches + (see [docs](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache)). + - ${noEffectOtherwise} + default: "" + + skip-restore-on-hit-primary-key: + description: | + - Can have an effect only when ${q restore-prefixes-first-match} has no effect. + - When `true`, when there's a hit on the ${q primary-key}, the action doesn't restore caches. + - ${noEffectOtherwise} + default: "false" + + fail-on: + description: | + - Input form: `.`. + - `` options: ${q primary-key}, `first-match`. + - `` options: `miss`, `not-restored`. + - When the input satisfies the input form, when the event described in the input happens, the action fails. + - Example: + - Input: `${primary-key}.not-restored`. + - Event: a cache could not be restored via the ${q primary-key}. + - ${noEffectOtherwise} + default: ""'' + else + "" + } + + nix: + description: | + - Can have an effect only when the action runs on a ${q linux} or a ${q macos} runner. + - When `true`, the action can do Nix-specific things. + - Otherwise, the action doesn't do them. + default: "true" + + save: + description: | + - When `true`, the action can save a cache with the ${q primary-key}. + - Otherwise, the action can't save a cache. + default: "true" + + ${paths}: + description: | + - When ${q nixTrue}, the action uses ${pathsDefault} as default paths, as suggested [here](https://github.com/divnix/nix-cache-action/blob/b14ec98ae694c754f57f8619ea21b6ab44ccf6e7/action.yml#L7). + - Otherwise, the action uses an empty list as default paths. + - ${pathsWhen} + - ${pathsOtherwise} + default: "" + ${paths}-macos: + description: | + - ${overrides paths} + - ${effectOnlyOn macos} + default: "" + ${paths}-linux: + description: | + - ${overrides paths} + - ${effectOnlyOn linux} + default: "" + + ${ + if target == "cache" || target == "save" then + '' + ${gc-max-store-size}: + description: | + - ${ + effectOnlyWhen [ + nixTrue + "save: true" + ] + } + - ${gcWhen} + - ${noEffectOtherwise} + default: "" + ${gc-max-store-size}-macos: + description: | + - ${overrides gc-max-store-size} + - ${effectOnlyOn macos} + default: "" + ${gc-max-store-size}-linux: + description: | + - ${overrides gc-max-store-size} + - ${effectOnlyOn linux} + default: "" + + purge: + description: | + - When `true`, the action purges (possibly zero) caches. + - ${noEffectOtherwise} + default: "false" + purge-${primary-key}: + description: | + - ${effectOnlyWhen [ "purge: true" ]} + - When `always`, the action always purges cache with the ${q primary-key}. + - When `never`, the action never purges cache with the ${q primary-key}. + - ${noEffectOtherwise}. + default: "" + purge-prefixes: + description: | + - ${effectOnlyWhen [ "purge: true" ]} + - ${whenListOf} cache key prefixes, the action selects for purging all caches whose keys match some of these prefixes and that are scoped to the current [GITHUB_REF](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables). + - ${noEffectOtherwise} + default: "" + purge-last-accessed: + description: | + - ${effectOnlyWhen [ "purge: true" ]} + - When a non-negative number, the action purges selected caches that were last accessed more than this number of seconds ago relative to the start of the `Post Restore` phase. + - ${noEffectOtherwise} + default: "" + purge-created: + description: | + - ${effectOnlyWhen [ "purge: true" ]} + - When a non-negative number, the action purges selected caches that were created more than this number of seconds ago relative to the start of the `Post Restore` phase. + - ${noEffectOtherwise} + default: "" + + upload-chunk-size: + # The original default value may be provided here (https://github.com/actions/cache/issues/1292) + # 32MB + description: | + - When a non-negative number, the action uses it as the chunk size (in bytes) to split up large files during upload. + - Otherwise, the action uses the default value `33554432` (32MB). + default: "" + + save-always: + description: 'Run the post step to save the cache even if another step before fails.' + default: 'false' + required: false '' - ${restore-prefixes-first-match}: + else + "" + } + + token: + description: The action uses it to communicate with GitHub API. + default: ''${{ github.token }} + ${ + if target == "cache" || target == "restore" then + '' + outputs: + ${primary-key}: description: | - - ${whenListOf} key prefixes, when there's a miss on the ${q primary-key}, - the action searches in this list for the first prefix for which there exists a cache - with a matching key and the action tries to restore that cache. - - ${noEffectOtherwise} - default: "" - restore-prefixes-all-matches: + - A string. + - The ${q primary-key}. + + hit: description: | - - ${whenListOf} key prefixes, the action tries to restore - all caches whose keys match these prefixes. - - Tries caches across all refs to make use of caches created - on the current, base, and default branches - (see [docs](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache)). - - ${noEffectOtherwise} - default: "" - - skip-restore-on-hit-primary-key: + - A boolean value. + - `true` when ${q hit-primary-key} is `true` or ${q hit-first-match} is `true`. + - `false` otherwise. + ${hit-primary-key}: description: | - - Can have an effect only when ${q restore-prefixes-first-match} has no effect. - - When `true`, when there's a hit on the ${q primary-key}, the action doesn't restore caches. - - ${noEffectOtherwise} - default: "false" - - fail-on: + - A boolean value. + - `true` when there was a hit on the ${q primary-key}. + - `false` otherwise. + ${hit-first-match}: description: | - - Input form: `.`. - - `` options: ${q primary-key}, `first-match`. - - `` options: `miss`, `not-restored`. - - When the input satisfies the input form, when the event described in the input happens, the action fails. - - Example: - - Input: `${primary-key}.not-restored`. - - Event: a cache could not be restored via the ${q primary-key}. - - ${noEffectOtherwise} - default: ""'' - else "" - } - - nix: - description: | - - Can have an effect only when the action runs on a ${q linux} or a ${q macos} runner. - - When `true`, the action can do Nix-specific things. - - Otherwise, the action doesn't do them. - default: "true" - - save: - description: | - - When `true`, the action can save a cache with the ${q primary-key}. - - Otherwise, the action can't save a cache. - default: "true" - - ${paths}: - description: | - - When ${q nixTrue}, the action uses ${pathsDefault} as default paths, as suggested [here](https://github.com/divnix/nix-cache-action/blob/b14ec98ae694c754f57f8619ea21b6ab44ccf6e7/action.yml#L7). - - Otherwise, the action uses an empty list as default paths. - - ${pathsWhen} - - ${pathsOtherwise} - default: "" - ${paths}-macos: - description: | - - ${overrides paths} - - ${effectOnlyOn macos} - default: "" - ${paths}-linux: - description: | - - ${overrides paths} - - ${effectOnlyOn linux} - default: "" - - ${ - if target == "cache" || target == "save" then - '' - ${gc-max-store-size}: - description: | - - ${effectOnlyWhen [nixTrue "save: true"]} - - ${gcWhen} - - ${noEffectOtherwise} - default: "" - ${gc-max-store-size}-macos: - description: | - - ${overrides gc-max-store-size} - - ${effectOnlyOn macos} - default: "" - ${gc-max-store-size}-linux: - description: | - - ${overrides gc-max-store-size} - - ${effectOnlyOn linux} - default: "" - - purge: - description: | - - When `true`, the action purges (possibly zero) caches. - - ${noEffectOtherwise} - default: "false" - purge-${primary-key}: - description: | - - ${effectOnlyWhen ["purge: true"]} - - When `always`, the action always purges cache with the ${q primary-key}. - - When `never`, the action never purges cache with the ${q primary-key}. - - ${noEffectOtherwise}. - default: "" - purge-prefixes: - description: | - - ${effectOnlyWhen ["purge: true"]} - - ${whenListOf} cache key prefixes, the action selects for purging all caches whose keys match some of these prefixes and that are scoped to the current [GITHUB_REF](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables). - - ${noEffectOtherwise} - default: "" - purge-last-accessed: - description: | - - ${effectOnlyWhen ["purge: true"]} - - When a non-negative number, the action purges selected caches that were last accessed more than this number of seconds ago relative to the start of the `Post Restore` phase. - - ${noEffectOtherwise} - default: "" - purge-created: - description: | - - ${effectOnlyWhen ["purge: true"]} - - When a non-negative number, the action purges selected caches that were created more than this number of seconds ago relative to the start of the `Post Restore` phase. - - ${noEffectOtherwise} - default: "" - - upload-chunk-size: - # The original default value may be provided here (https://github.com/actions/cache/issues/1292) - # 32MB - description: | - - When a non-negative number, the action uses it as the chunk size (in bytes) to split up large files during upload. - - Otherwise, the action uses the default value `33554432` (32MB). - default: "" - - save-always: - description: 'Run the post step to save the cache even if another step before fails.' - default: 'false' - required: false - '' - else ""} + - A boolean value. + - `true` when there was a hit on a key matching ${q restore-prefixes-first-match}. + - `false` otherwise. - token: - description: The action uses it to communicate with GitHub API. - default: ''${{ github.token }} - ${ - if target == "cache" || target == "restore" then - '' - outputs: - ${primary-key}: - description: | - - A string. - - The ${q primary-key}. - - hit: - description: | - - A boolean value. - - `true` when ${q hit-primary-key} is `true` or ${q hit-first-match} is `true`. - - `false` otherwise. - ${hit-primary-key}: - description: | - - A boolean value. - - `true` when there was a hit on the ${q primary-key}. - - `false` otherwise. - ${hit-first-match}: - description: | - - A boolean value. - - `true` when there was a hit on a key matching ${q restore-prefixes-first-match}. - - `false` otherwise. - - restored-key: - description: | - - A string. - - The key of a cache restored via the ${q primary-key} or via the ${q restore-prefixes-first-match}. - - An empty string otherwise. - - restored-keys: - description: | - - A possibly empty array of strings (JSON). - - Keys of restored caches. - - Example: `["key1", "key2"]`.'' - else "" - } - runs: - using: "node20" - main: "${specific.main}" - ${specific.post} - branding: - icon: "archive" - color: "gray-dark"'' + restored-key: + description: | + - A string. + - The key of a cache restored via the ${q primary-key} or via the ${q restore-prefixes-first-match}. + - An empty string otherwise. + + restored-keys: + description: | + - A possibly empty array of strings (JSON). + - Keys of restored caches. + - Example: `["key1", "key2"]`.'' + else + "" + } + runs: + using: "node20" + main: "${specific.main}" + ${specific.post} + branding: + icon: "archive" + color: "gray-dark"'' diff --git a/flake.lock b/flake.lock index 71f3af35..3ff13600 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,236 @@ { "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713447246, + "narHash": "sha256-lafrzPN19LdRC3S0s6moAjI5ICyY9HSE1EJAXiEBLAw=", + "owner": "deemp", + "repo": "devshell", + "rev": "eece9ce8466060972c2f8aa332b7e7263ad115d6", + "type": "github" + }, + "original": { + "owner": "deemp", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "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" + } + }, "flakes": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1712758784, + "narHash": "sha256-0llM59XV+3tOvrYqAX/i1EaU3gK9hsK3N0A7VzHUMoI=", + "owner": "deemp", + "repo": "flakes", + "rev": "fe9f34bf093d0d729287438e8a2b882192875a9f", + "type": "github" + }, + "original": { + "owner": "deemp", + "repo": "flakes", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, "locked": { - "lastModified": 1701565135, - "narHash": "sha256-Jn3jHSxmh8bRzQZfzpXHPPLegYsQuLLX37Rqga7o4kg=", + "dir": "pins/nixpkgs", + "lastModified": 1706403361, + "narHash": "sha256-/gpmOBW2C1zmKhE/skCv2P73pjpVO0+sXkHy6MWhqKQ=", "owner": "deemp", "repo": "flakes", - "rev": "89e3544d98be7c8cf58dc254f9119f5e7adb3880", + "rev": "0ac75a3908fd4bf358b53b1759c216be5a2ca2e5", "type": "github" }, "original": { + "dir": "pins/nixpkgs", "owner": "deemp", "repo": "flakes", "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1704321053, + "narHash": "sha256-r8KVHIxSA9hB4KNGyAf2ltEJXpDELX5Q1sIXpWAf9Tg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "efc960b6d6a6498c23868f4ba59fcb8bb51c9861", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "efc960b6d6a6498c23868f4ba59fcb8bb51c9861", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1714184256, + "narHash": "sha256-/VyiyGD2q6qN/uAvotKxXuQJWLlmSckAdf7S8jj4Q5c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "698fd43e541a6b8685ed408aaf7a63561018f9f8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { - "flakes": "flakes" + "devshell": "devshell", + "flake-parts": "flake-parts", + "flakes": "flakes", + "nixpkgs": "nixpkgs_4", + "systems": "systems_2", + "treefmt-nix": "treefmt-nix" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_5" + }, + "locked": { + "lastModified": 1714058656, + "narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index c080d3ae..aa172abd 100644 --- a/flake.nix +++ b/flake.nix @@ -1,33 +1,77 @@ { - inputs.flakes.url = "github:deemp/flakes"; - outputs = inputs: - let flakes = inputs.flakes; in - flakes.makeFlake { - inputs = { - inherit (flakes.all) nixpkgs devshell drv-tools; - }; - perSystem = { inputs, system }: + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + systems.url = "github:nix-systems/default"; + devshell.url = "github:deemp/devshell"; + flakes.url = "github:deemp/flakes"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = with inputs; [ + devshell.flakeModule + treefmt-nix.flakeModule + ]; + systems = import inputs.systems; + perSystem = + { + pkgs, + lib, + system, + config, + ... + }: let - pkgs = inputs.nixpkgs.legacyPackages.${system}; - inherit (inputs.devshell.lib.${system}) mkCommands mkRunCommands mkRunCommandsDir mkShell; - inherit (inputs.drv-tools.lib.${system}) writeYAML mkShellApps getExe; + inherit (inputs.flakes.lib.${system}.drv-tools) mkShellApps; - + writeYAML = + path: value: + pkgs.writeShellApplication { + name = "write"; + text = '' + cat > ${path} <<'EOF' + ${value} + EOF + ''; + }; + in + { packages = mkShellApps { - writeSave = writeYAML "save" "save/action.yml" (import ./action.nix { target = "save"; inherit (pkgs) lib; }); - writeRestore = writeYAML "restore" "restore/action.yml" (import ./action.nix { target = "restore"; inherit (pkgs) lib; }); - writeCache = writeYAML "cache" "action.yml" (import ./action.nix { target = "cache"; inherit (pkgs) lib; }); + writeSave = writeYAML "save/action.yml" ( + import ./action.nix { + target = "save"; + inherit (pkgs) lib; + } + ); + + writeRestore = writeYAML "restore/action.yml" ( + import ./action.nix { + target = "restore"; + inherit (pkgs) lib; + } + ); + + writeCache = writeYAML "action.yml" ( + import ./action.nix { + target = "cache"; + inherit (pkgs) lib; + } + ); + writeActions = { text = '' - ${getExe packages.writeSave} - ${getExe packages.writeRestore} - ${getExe packages.writeCache} + ${lib.getExe config.packages.writeSave} + ${lib.getExe config.packages.writeRestore} + ${lib.getExe config.packages.writeCache} ''; }; + write = { runtimeInputs = [ pkgs.nodejs_20 ]; text = '' - ${getExe packages.writeActions} + ${lib.getExe config.packages.writeActions} npm run readme npm run format ''; @@ -46,13 +90,23 @@ description = "build project"; }; }; - devShells.default = mkShell { + + devshells.default = { packages = [ pkgs.nodejs_20 ]; - commands = mkRunCommands "scripts" { inherit (packages) write install build; }; + commands.scripts = [ + { + prefix = "nix run .#"; + packages = { + inherit (config.packages) write install build; + }; + } + ]; + }; + + treefmt = { + projectRootFile = "flake.nix"; + programs.nixfmt-rfc-style.enable = true; }; - in - { - inherit packages devShells; }; };