diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6a67036 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 +indent_style = space +indent_size = 2 diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3b3248a --- /dev/null +++ b/.envrc @@ -0,0 +1,17 @@ +#! /bin/sh + +# SPDX-FileCopyrightText: 2022 David Arnold +# SPDX-FileCopyrightText: 2022 Kevin Amado +# +# SPDX-License-Identifier: Unlicense + +source "$( + nix eval \ + --no-update-lock-file \ + --no-write-lock-file \ + --no-warn-dirty \ + --accept-flake-config \ + .#__std.direnv_lib 2>/dev/null \ + || nix eval .#__std.direnv_lib # show the errors +)" +use std cells //_automation/devshells:default diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..45b42e1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,28 @@ +name: Test all package sets + +on: + push: + branches: + - main + merge_request: + workflow_dispatch: + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.1.0 + + - name: Install latest nix + uses: cachix/install-nix-action@v18 + with: + extra_nix_config: | + substituters = https://cache.nixos.org https://nix-community.cachix.org https://fog.cachix.org + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs= fog.cachix.org-1:FAxiA6qMLoXEUdEq+HaT24g1MjnxdfygrbrLDBp6U/s= + nix_path: nixpkgs=channel:nixos-unstable + + - name: Quick eval + run: nix develop --show-trace --print-build-logs --command evalnix + + - name: Run all tests + run: nix develop --show-trace --print-build-logs .#devShells.x86_64-linux.checks --command run-all diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5a7781 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2022 David Arnold +# SPDX-FileCopyrightText: 2022 Kevin Amado +# +# SPDX-License-Identifier: Unlicense + +.std +/**/flake.lock +result +.direnv diff --git a/bud/default.nix b/bud/default.nix deleted file mode 100644 index 204114f..0000000 --- a/bud/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs, lib, budUtils, ... }: { - bud.cmds = with pkgs; { - vscode-ext-prefetch = { - writer = budUtils.writeBashWithPaths [ curl jq ]; - synopsis = "vscode-ext-prefetch"; - help = "Prefetch meta for vscode extensions"; - script = ./vscode-ext-prefetch.bash; - }; - }; -} diff --git a/bud/vscode-ext-prefetch.bash b/bud/vscode-ext-prefetch.bash deleted file mode 100755 index 28de9b5..0000000 --- a/bud/vscode-ext-prefetch.bash +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -id="$1" -query="$(curl -s https://open-vsx.org/api/$id)" -type="openvsx" -namespace="$(echo $query | jq --raw-output '.namespace')" -if [ "$namespace" = "null" ]; then exit 1; fi -extension="$(echo $query | jq --raw-output '.name')" -license="$(echo $query | jq --raw-output '.license')" -repo="$(echo $query | jq --raw-output '.repository')" -description="$(echo $query | jq --raw-output '.description')" -echo "[$extension]" -echo "src.$type = \"$namespace.$extension\"" -echo "fetch.$type = \"$namespace.$extension\"" -echo "passthru = { license = \"${license,,}\", homepage = \"$repo\", description = \"$description\" }" -echo "" diff --git a/cells/_automation/devshells.nix b/cells/_automation/devshells.nix new file mode 100644 index 0000000..85c55aa --- /dev/null +++ b/cells/_automation/devshells.nix @@ -0,0 +1,80 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) cells nixpkgs std; +in + l.mapAttrs (_: std.lib.dev.mkShell) { + default = { + extraModulesPath, + pkgs, + ... + }: { + name = "devos-ext-lib"; + + git.hooks = { + enable = true; + pre-commit.text = builtins.readFile ./devshells/pre-flight-check.sh; + }; + + imports = [ + std.std.devshellProfiles.default + "${extraModulesPath}/git/hooks.nix" + ]; + + packages = [ + # formatters + nixpkgs.alejandra + ]; + + commands = with cell.lib.categories; [ + (formatters nixpkgs.treefmt) + (formatters nixpkgs.editorconfig-checker) + (legal nixpkgs.reuse) + (utils { + name = "evalnix"; + help = "Check Nix parsing"; + command = "${nixpkgs.fd}/bin/fd --extension nix --exec ${nixpkgs.nix}/bin/nix-instantiate --parse --quiet {} >/dev/null"; + }) + (utils cell.packages.repl) + ]; + }; + + checks = {...}: { + name = "checks"; + imports = [std.std.devshellProfiles.default]; + commands = let + tests = cells.std.lib.trimBy cells ["tests"]; + testToCommand = l.mapAttrsToList (otherCell: targets: let + targetToTest = + l.mapAttrsToList (targetName: value: { + name = otherCell + "-" + targetName; + command = l.concatStringsSep "; " [ + "echo -n '${value.description} \n => '" + ( + if value.result == value.expected + then "echo 'PASSED!'" + else "echo 'FAILED! Run `nix develop .#devShells.${nixpkgs.system}.default --command repl` to inspect the problem. \n => trace: Flake.${nixpkgs.system}.${otherCell}.tests.${targetName}'; export checks=1" + ) + ]; + }) + targets; + in + targetToTest) + tests; + testCommands = l.flatten testToCommand; + testNames = l.catAttrs "name" testCommands; + in + [ + { + name = "run-all"; + command = l.concatStringsSep "; " (testNames + ++ [ + "[[ -z \${checks+x} ]] && echo 'All tests passed!' || { echo 'Some tests failed!' && exit 1; }" + ]); + } + ] + ++ testCommands; + }; + } diff --git a/cells/_automation/devshells/pre-flight-check.sh b/cells/_automation/devshells/pre-flight-check.sh new file mode 100644 index 0000000..aece6d8 --- /dev/null +++ b/cells/_automation/devshells/pre-flight-check.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2022 The Standard Authors +# SPDX-FileCopyrightText: 2022 Kevin Amado +# +# SPDX-License-Identifier: Unlicense + +if git rev-parse --verify HEAD >/dev/null 2>&1; then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(${git}/bin/git hash-object -t tree /dev/null) +fi + +diff="git diff-index --name-only --cached $against --diff-filter d" +all_files=($($diff)) + +# Format the entire tree. +treefmt + +# check editorconfig +editorconfig-checker -- "${all_files[@]}" +if [[ $? != '0' ]]; then + printf "%b\n" \ + "\nCode is not aligned with .editorconfig" \ + "Review the output and commit your fixes" >&2 + exit 1 +fi diff --git a/cells/_automation/lib.nix b/cells/_automation/lib.nix new file mode 100644 index 0000000..468cf0c --- /dev/null +++ b/cells/_automation/lib.nix @@ -0,0 +1,36 @@ +{ + inputs, + cell, +}: let + l = inputs.nixpkgs.lib // builtins; + + cmdWithCategory = category: attrs: attrs // {inherit category;}; + + pkgWithCategory = category: package: cmdWithCategory category {inherit package;}; + + withCategory = category: attrs: let + mapWith = + if l.isDerivation attrs + then pkgWithCategory + else cmdWithCategory; + in + mapWith category attrs; + + mkCategories = categories: attrs: let + withCategories = l.genAttrs categories (category: withCategory category); + in + withCategories // attrs; + + categories = [ + "cli-dev" + "devos" + "docs" + "formatters" + "legal" + "utils" + ]; +in { + categories = mkCategories categories { + inherit cmdWithCategory pkgWithCategory withCategory categories; + }; +} diff --git a/cells/_automation/packages.nix b/cells/_automation/packages.nix new file mode 100644 index 0000000..9a3cfd4 --- /dev/null +++ b/cells/_automation/packages.nix @@ -0,0 +1,14 @@ +{ + inputs, + cell, +}: let + inherit (inputs) nixpkgs; +in { + repl = nixpkgs.writeShellScriptBin "repl" '' + if [ -z "$1" ]; then + nix repl --argstr host "$HOST" --argstr flakePath "$PRJ_ROOT" --file ${./packages/repl/repl.nix} + else + nix repl --argstr host "$HOST" --argstr flakePath $(readlink -f $1 | sed 's|/flake.nix||') --file ${./packages/repl/repl.nix} ''${@: 1} + fi + ''; +} diff --git a/cells/_automation/packages/repl/repl.nix b/cells/_automation/packages/repl/repl.nix new file mode 100644 index 0000000..1253eaf --- /dev/null +++ b/cells/_automation/packages/repl/repl.nix @@ -0,0 +1,23 @@ +# Adapted on 3rd of July 2021 from +# https://github.com/gytis-ivaskevicius/flake-utils-plus/blob/438316a7b7d798bff326c97da8e2b15a56c7657e/lib/repl.nix +{ + flakePath, + host, +}: let + Flake = + if builtins.pathExists flakePath + then builtins.getFlake (toString flakePath) + else {}; + + Me = Flake.nixosConfigurations.${host} or {}; + Channels = Flake.pkgs.${builtins.currentSystem} or {}; + + LoadFlake = path: builtins.getFlake (toString path); +in { + inherit + Channels + Flake + LoadFlake + Me + ; +} diff --git a/cells/devos-ext/lib.nix b/cells/devos-ext/lib.nix new file mode 100644 index 0000000..085003a --- /dev/null +++ b/cells/devos-ext/lib.nix @@ -0,0 +1,136 @@ +{ + inputs, + cell, +}: let + l = inputs.nixpkgs.lib // builtins // cell.lib; +in { + /* + A function that do nothing with any given attributes. + + The transformation is: src.* -> src.* + + You can typically use this function when you don't want to + filter out any attributes, such as when providing `src` an attribute set + that has already been filtered. + Example: + ```nix + # src + { + packagesA-helper1 = ...; + packagesA-helper2 = ...; + packagesB = ...; + } + # dontFilterSrc src + { + packagesA-helper1 = ...; + packagesA-helper2 = ...; + packagesB = ...; + } + */ + dontFilterSrc = _: l.id; + + /* + A function that filters out any attributes that doesn't match `prefix`. + + The transformation is: src.* -> src.prefix^ + + You can typically use this function when composing a packages builder + with `mkPackagesBuilder`. + Example: + ```nix + # src + { + packagesA-helper3 = ...; + packagesA-helper4 = ...; + packagesB = ...; + } + # filterSrc "packagesA-" src + { + packagesA-helper3 = ...; + packagesA-helper4 = ...; + } + ``` + */ + filterSrc = prefix: + l.filterAttrs + (name: _: l.hasPrefix prefix name); + + /* + A function that filters out any attributes that doesn't match `prefix`, + and removes `prefix` from its attribute names. + + The transformation is: src.* -> src.prefix^ -> src.^ + + You can typically use this function when composing a packages builder + with `mkPackagesBuilder`. + Example: + ```nix + # src + { + packagesA-helper3 = ...; + packagesA-helper4 = ...; + packagesB = ...; + } + # filterSrc' "packagesA-" src + { + helper3 = ...; + helper4 = ...; + } + ``` + */ + filterSrc' = prefix: src: let + matches = l.filterSrc prefix src; + removePrefix = name: l.nameValuePair (l.removePrefix prefix name); + in + l.mapAttrs' removePrefix matches; + + /* + A function that returns an overlay that injects a builder's library to `pkgs.lib` and `lib` + as `pkgs.lib.${args.pname}` and `lib.${args.pname}` + + The transformation is: args -> final: prev: + + `args` is an argument with the following attributes: + { + pname = string; + lib = attrs; + } + + Example: + ```nix + # args + { + pname = "packagesA"; + lib = { + builder = ; + builders = { + default = ; + ...; + }; + ...; + }; + } + # mkBuilderOverlay args + final: prev: { + lib = prev.lib.extends (lfinal: lprev: { + packagesA = { + builder = ; + builders = { + default = ; + ...; + }; + ...; + }; + }); + } + ``` + */ + mkBuilderOverlay = { + pname, + builders, + }: final: prev: { + lib = prev.lib.extend (lfinal: lprev: { + ${pname} = {inherit builders;}; + }); + }; +} diff --git a/cells/devos-ext/overlays.nix b/cells/devos-ext/overlays.nix new file mode 100644 index 0000000..973bbb5 --- /dev/null +++ b/cells/devos-ext/overlays.nix @@ -0,0 +1,10 @@ +{ + inputs, + cell, +}: { + default = final: prev: { + lib = prev.lib.extend (lfinal: lprev: { + devos-ext = cell.lib; + }); + }; +} diff --git a/cells/minecraft-mods/builders.nix b/cells/minecraft-mods/builders.nix new file mode 100644 index 0000000..29d773a --- /dev/null +++ b/cells/minecraft-mods/builders.nix @@ -0,0 +1,71 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; +in { + default = { + srcs, + prefix ? "minecraft-mod", + stdenv ? nixpkgs.stdenv, + fd ? nixpkgs.fd, + unzip ? nixpkgs.unzip, + }: let + builder = modName: { + src, + version, + compatibility ? "any", + id ? modName, + meta ? {}, + matchers ? [ + ".*-SNAPSHOT.jar" + ''.*[.*|\d+\.\d+\.\d+].jar'' + ".*[fabric|forge].*.jar" + ], + ... + } @ modArgs: let + otherArguments = + l.removeAttrs modArgs + [ + "compatibility" + "id" + "matchers" + ]; + in + stdenv.mkDerivation (final: + l.flip l.recursiveUpdate otherArguments { + dontUnpack = l.hasSuffix ".jar" src.name; + + pname = prefix + "-" + modName; + + nativeBuildInputs = + [fd] + ++ l.optionals (!final.dontUnpack) [unzip]; + + unpackPhase = l.optionalString (!final.dontUnpack) '' + unzip "$src" + ''; + + installPhase = '' + mkdir -p "$out/share/java" + ${ + if final.dontUnpack + then ''ln -s "$src" .'' + else "fd '.*dev|sources.jar' -X rm" + } + ${l.concatMapStrings + (e: '' + fd '${e}' -x mv {} "$out/share/java/${modName}-$version.jar" + '') + matchers} + ''; + + passthru = { + minecraft = {inherit compatibility;}; + modrinth.id = l.mkIf (id != modName) id; + }; + }); + in + l.mapAttrs builder srcs; +} diff --git a/cells/minecraft-mods/overlays.nix b/cells/minecraft-mods/overlays.nix new file mode 100644 index 0000000..6102e77 --- /dev/null +++ b/cells/minecraft-mods/overlays.nix @@ -0,0 +1,9 @@ +{ + inputs, + cell, +}: { + minecraft-mods = inputs.cells.devos-ext.lib.mkBuilderOverlay { + pname = "minecraft-mods"; + inherit (cell) builders; + }; +} diff --git a/cells/papermc/builders.nix b/cells/papermc/builders.nix new file mode 100644 index 0000000..758e2ba --- /dev/null +++ b/cells/papermc/builders.nix @@ -0,0 +1,36 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; +in { + default = { + srcs, + papermc ? nixpkgs.papermc, + pkgs, + }: let + builder = pname: { + src, + version, + mcVersion, + meta ? papermc.meta, + ... + } @ pArgs: let + otherArguments = l.removeAttrs pArgs [ + "pname" + "version" + ]; + + drvOverride = papermc.override { + jre = pkgs."${cell.lib.jreMcVersion mcVersion}"; + }; + in + drvOverride.overrideAttrs (_: + l.flip l.recursiveUpdate otherArguments { + passthru.mcVer = mcVersion; + version = "${mcVersion}r${version}"; + }); + in + l.mapAttrs builder srcs; +} diff --git a/cells/papermc/lib.nix b/cells/papermc/lib.nix new file mode 100644 index 0000000..87ec720 --- /dev/null +++ b/cells/papermc/lib.nix @@ -0,0 +1,17 @@ +{ + inputs, + cell, +}: { + # based on https://www.creeperhost.net/wiki/books/minecraft-java-edition/page/changing-java-versions + jreMcVersion = version: let + jre = + { + "1.17" = ["jre8"]; + "1.18" = ["adoptopenjdk-jre-openj9-bin-16"]; + "1.19" = ["javaPackages" "compiler" "openjdk17" "headless"]; + } + .${version} + or ["jre_headless"]; + in + jre; +} diff --git a/cells/papermc/overlays.nix b/cells/papermc/overlays.nix new file mode 100644 index 0000000..f618492 --- /dev/null +++ b/cells/papermc/overlays.nix @@ -0,0 +1,9 @@ +{ + inputs, + cell, +}: { + papermc = inputs.cells.devos-ext.lib.mkBuilderOverlay { + pname = "papermc"; + inherit (cell) builders; + }; +} diff --git a/cells/python-modules/builders.nix b/cells/python-modules/builders.nix new file mode 100644 index 0000000..752067f --- /dev/null +++ b/cells/python-modules/builders.nix @@ -0,0 +1,20 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; +in { + default = { + srcs, + python3Packages ? nixpkgs.python3Packages, + } @ args: let + builder = pname': { + pname ? pname', + doCheck ? false, + ... + } @ pArgs: + python3Packages.buildPythonPackage pArgs; + in + l.mapAttrs builder srcs; +} diff --git a/cells/python-modules/overlays.nix b/cells/python-modules/overlays.nix new file mode 100644 index 0000000..e15dd51 --- /dev/null +++ b/cells/python-modules/overlays.nix @@ -0,0 +1,9 @@ +{ + inputs, + cell, +}: { + python3Packages = inputs.cells.devos-ext.lib.mkBuilderOverlay { + pname = "python3Packages"; + inherit (cell) builders; + }; +} diff --git a/cells/std/lib.nix b/cells/std/lib.nix new file mode 100644 index 0000000..3bc9ef2 --- /dev/null +++ b/cells/std/lib.nix @@ -0,0 +1,43 @@ +{ + inputs, + cell, +}: let + l = inputs.nixpkgs.lib // builtins; + + inherit + (l) + attrValues + filterAttrs + foldl' + getAttrFromPath + hasAttrByPath + mapAttrs + recursiveUpdate + ; +in rec { + # TODO: upstream the code to divnix/std + # TODO: std lib documentation + # TODO: better way to do these + gather = cells: targets: + filterAttrs + (cell: organelle: hasAttrByPath targets organelle) + cells; + + select = cells: targets: + mapAttrs + (cell: organelle: getAttrFromPath targets organelle) + cells; + + trim = cells: targets: let + selectors = trimBy cells targets; + in + foldl' recursiveUpdate {} + (attrValues selectors); + + trimBy = cells: targets: + select + ( + gather cells targets + ) + targets; +} diff --git a/cells/vim-plugins/builders.nix b/cells/vim-plugins/builders.nix new file mode 100644 index 0000000..9adfa00 --- /dev/null +++ b/cells/vim-plugins/builders.nix @@ -0,0 +1,16 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; +in { + default = { + srcs, + vimUtils ? nixpkgs.vimUtils, + }: let + builder = fallbackPname: {pname ? fallbackPname, ...} @ pArgs: + vimUtils.buildVimPluginFrom2Nix pArgs; + in + l.mapAttrs builder srcs; +} diff --git a/cells/vim-plugins/overlays.nix b/cells/vim-plugins/overlays.nix new file mode 100644 index 0000000..bda570f --- /dev/null +++ b/cells/vim-plugins/overlays.nix @@ -0,0 +1,9 @@ +{ + inputs, + cell, +}: { + vimPlugins = inputs.cells.devos-ext.lib.mkBuilderOverlay { + pname = "vimUtils"; + inherit (cell) builders; + }; +} diff --git a/cells/vim-plugins/tests.nix b/cells/vim-plugins/tests.nix new file mode 100644 index 0000000..7eaeff7 --- /dev/null +++ b/cells/vim-plugins/tests.nix @@ -0,0 +1,40 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; + + srcs = { + ferret = { + pname = "ferret"; + version = "2022-06-12"; + src = nixpkgs.fetchFromGitHub { + owner = "wincent"; + repo = "ferret"; + rev = "3d064304876941e4197db6b4264db6b72bd9f83d"; + fetchSubmodules = false; + sha256 = "1lkznmavw2f4ckh3yjjvdhja313ia0aayn5pkf6ygjny1089gcih"; + }; + meta.homepage = "https://github.com/wincent/ferret/"; + }; + yuck = { + pname = "yuck"; + version = "6dc3da77c53820c32648cf67cbdbdfb6994f4e08"; + src = nixpkgs.fetchFromGitHub { + owner = "elkowar"; + repo = "yuck.vim"; + rev = "6dc3da77c53820c32648cf67cbdbdfb6994f4e08"; + fetchSubmodules = false; + sha256 = "sha256-lp7qJWkvelVfoLCyI0aAiajTC+0W1BzDhmtta7tnICE="; + }; + }; + }; +in { + default = { + inherit srcs; + description = "tests.vim-plugins.default: can generate a package from source."; + result = cell.builders.default {inherit srcs;}; + expected = l.mapAttrs (_: nixpkgs.vimUtils.buildVimPluginFrom2Nix) srcs; + }; +} diff --git a/cells/vscode-extensions/builders.nix b/cells/vscode-extensions/builders.nix new file mode 100644 index 0000000..67baed5 --- /dev/null +++ b/cells/vscode-extensions/builders.nix @@ -0,0 +1,66 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) cells nixpkgs; +in { + default = cell.builders.no-namespace; + + no-namespace = { + srcs, + vscode-utils ? nixpkgs.vscode-utils, + libarchive ? nixpkgs.libarchive, + vscodium ? nixpkgs.vscodium, + }: let + builder = extName: { + src, + version, + name ? extName, + publisher, + meta ? {}, + ... + } @ extArgs: let + otherArguments = + l.removeAttrs extArgs + [ + "src" + "pname" + "name" + "publisher" + "version" + ]; + + drv = vscode-utils.buildVscodeMarketplaceExtension (l.flip l.recursiveUpdate otherArguments { + vsix = src; + mktplcRef = {inherit version name publisher;}; + buildInputs = [libarchive]; + unpackPhase = '' + bsdtar xvf "$src" --strip-components=1 'extension/*' + ''; + meta.platforms = + if meta ? platforms + then meta.platforms + else vscodium.meta.platforms; + }); + in + l.nameValuePair (l.toLower extName) drv; + in + l.mapAttrs' builder srcs; + + with-namespace = { + srcs, + vscode-utils ? nixpkgs.vscode-utils, + libarchive ? nixpkgs.libarchive, + vscodium ? nixpkgs.vscodium, + } @ args: let + srcsByPublisher = l.groupBy (x: l.toLower x.publisher) (l.attrValues srcs); + builder = publisher: exts: + l.listToAttrs (l.map (value: { + name = l.toLower value.name; + inherit (cell.builders.no-namespace (args // {srcs = {inherit value;};})) value; + }) + exts); + in + l.mapAttrs builder srcsByPublisher; +} diff --git a/cells/vscode-extensions/overlays.nix b/cells/vscode-extensions/overlays.nix new file mode 100644 index 0000000..b9ed9d0 --- /dev/null +++ b/cells/vscode-extensions/overlays.nix @@ -0,0 +1,9 @@ +{ + inputs, + cell, +}: { + vscode-extensions = inputs.cells.devos-ext.lib.mkBuilderOverlay { + pname = "vscode-utils"; + inherit (cell) builders; + }; +} diff --git a/cells/vscode-extensions/tests.nix b/cells/vscode-extensions/tests.nix new file mode 100644 index 0000000..9888d73 --- /dev/null +++ b/cells/vscode-extensions/tests.nix @@ -0,0 +1,106 @@ +{ + inputs, + cell, +}: let + l = nixpkgs.lib // builtins; + inherit (inputs) nixpkgs; + + srcs = { + arrterian-nix-env-selector = { + pname = "arrterian-nix-env-selector"; + version = "1.0.9"; + src = nixpkgs.fetchurl { + url = "https://open-vsx.org/api/arrterian/nix-env-selector/1.0.9/file/arrterian.nix-env-selector-1.0.9.vsix"; + sha256 = "sha256-KPVH74+gjDbjBLYtTOrTWEVcDB41oMn4cqK3/Yubhzs="; + }; + name = "nix-env-selector"; + publisher = "arrterian"; + meta = { + license = [l.licenses.mit]; + description = "Allows switch environment for Visual Studio Code and extensions based on Nix config file."; + }; + }; + + bbenoist-Nix = { + pname = "bbenoist-Nix"; + version = "1.0.1"; + src = nixpkgs.fetchurl { + url = "https://open-vsx.org/api/bbenoist/Nix/1.0.1/file/bbenoist.Nix-1.0.1.vsix"; + sha256 = "sha256-KaEd0ek/PtRQQ/jjiXO+sZ0hFqZAhFUE/gbN/NZwQoE="; + }; + name = "Nix"; + publisher = "bbenoist"; + meta = { + license = [l.licenses.mit]; + description = "Nix language support for Visual Studio Code."; + }; + }; + }; +in { + no-namespace = { + inherit srcs; + + description = "tests.vscode-extensions.no-namespace: can generate a package as \${publisher}-\${name}."; + + result = cell.builders.no-namespace {inherit srcs;}; + + expected = let + common = { + buildInputs = [nixpkgs.libarchive]; + unpackPhase = '' + bsdtar xvf "$src" --strip-components=1 'extension/*' + ''; + meta.platforms = nixpkgs.vscodium.meta.platforms; + }; + expectedBuilder = args: nixpkgs.vscode-utils.buildVscodeMarketplaceExtension (l.recursiveUpdate common args); + in { + arrterian-nix-env-selector = expectedBuilder { + vsix = nixpkgs.fetchurl { + url = "https://open-vsx.org/api/arrterian/nix-env-selector/1.0.9/file/arrterian.nix-env-selector-1.0.9.vsix"; + sha256 = "sha256-KPVH74+gjDbjBLYtTOrTWEVcDB41oMn4cqK3/Yubhzs="; + }; + mktplcRef = { + version = "1.0.9"; + name = "nix-env-selector"; + publisher = "arrterian"; + }; + meta = { + license = [l.licenses.mit]; + description = "Allows switch environment for Visual Studio Code and extensions based on Nix config file."; + }; + }; + bbenoist-nix = expectedBuilder { + vsix = nixpkgs.fetchurl { + url = "https://open-vsx.org/api/bbenoist/Nix/1.0.1/file/bbenoist.Nix-1.0.1.vsix"; + sha256 = "sha256-KaEd0ek/PtRQQ/jjiXO+sZ0hFqZAhFUE/gbN/NZwQoE="; + }; + mktplcRef = { + version = "1.0.1"; + name = "Nix"; + publisher = "bbenoist"; + }; + meta = { + license = [l.licenses.mit]; + description = "Nix language support for Visual Studio Code."; + }; + }; + }; + }; + + with-namespace = { + inherit srcs; + + description = "tests.vscode-extensions.with-namespace: can generate a package as \${publisher}.\${name}."; + + result = cell.builders.with-namespace {inherit srcs;}; + + expected = l.mapAttrs' (n: v: let + expectedPublisher = l.toLower v.publisher; + expectedName = l.toLower v.name; + in + l.nameValuePair expectedPublisher { + ${expectedName} = cell.tests.no-namespace.expected."${expectedPublisher}-${expectedName}"; + }) + srcs; + }; +} diff --git a/default.nix b/default.nix deleted file mode 100644 index b1328d4..0000000 --- a/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ inputs, self, system ? builtins.currentSystem }: -let - flatten' = builtins.foldl' (a: b: a ++ b) [ ]; - - pkgs = import inputs.nixpkgs { - inherit system; - config = { }; - overlays = flatten' (builtins.attrValues { - inherit (self.overlays) - minecraft-mods - papermc - python3Packages - vimPlugins - vscode-extensions - ; - }); - }; -in -{ - inherit (pkgs) - lib - - minecraft-mods-builder - minecraft-utils - - papermc-pkgs-builder - papermc-utils - - python3Packages-builder - python3Packages-utils - - vimPlugins-builder - vimUtils - - vscode-extensions-builder - vscode-utils - ; -} diff --git a/flake.lock b/flake.lock index 74e0e24..9a96b6e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,274 @@ { "nodes": { + "blank": { + "locked": { + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "blank", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1663445644, + "narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=", + "owner": "numtide", + "repo": "devshell", + "rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "dmerge": { + "inputs": { + "nixlib": [ + "std", + "nixpkgs" + ], + "yants": [ + "std", + "yants" + ] + }, + "locked": { + "lastModified": 1659548052, + "narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=", + "owner": "divnix", + "repo": "data-merge", + "rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "data-merge", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "incl": { + "inputs": { + "nixlib": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1669064039, + "narHash": "sha256-pQVq4ZmUcU46kaGAYQwlwpNHmL+jFNuQm3TYDZChggQ=", + "owner": "divnix", + "repo": "incl", + "rev": "6793404bbada643beef45abb8d2d646db9a3ba66", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "incl", + "type": "github" + } + }, + "mdbook-kroki-preprocessor": { + "flake": false, + "locked": { + "lastModified": 1661755005, + "narHash": "sha256-1TJuUzfyMycWlOQH67LR63/ll2GDZz25I3JfScy/Jnw=", + "owner": "JoelCourtney", + "repo": "mdbook-kroki-preprocessor", + "rev": "93adb5716d035829efed27f65f2f0833a7d3e76f", + "type": "github" + }, + "original": { + "owner": "JoelCourtney", + "repo": "mdbook-kroki-preprocessor", + "type": "github" + } + }, + "n2c": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1665039323, + "narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, + "nixago": { + "inputs": { + "flake-utils": [ + "std", + "flake-utils" + ], + "nixago-exts": [ + "std", + "blank" + ], + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1661824785, + "narHash": "sha256-/PnwdWoO/JugJZHtDUioQp3uRiWeXHUdgvoyNbXesz8=", + "owner": "nix-community", + "repo": "nixago", + "rev": "8c1f9e5f1578d4b2ea989f618588d62a335083c3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixago", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1638330963, - "narHash": "sha256-Xp5YJPzYImZCRDjXqc5STDey/i8ikWa6Y5tADpI5+5I=", - "owner": "nixos", + "lastModified": 1669140675, + "narHash": "sha256-npzfyfLECsJWgzK/M4gWhykP2DNAJTYjgY2BWkz/oEQ=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "c7b4ee906c957538e65599e6c43046f2a3c6fb97", + "rev": "2788904d26dda6cfa1921c5abb7a2466ffe3cb8c", "type": "github" }, "original": { - "owner": "nixos", - "ref": "release-21.11", + "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, + "nosys": { + "locked": { + "lastModified": 1667881534, + "narHash": "sha256-FhwJ15uPLRsvaxtt/bNuqE/ykMpNAPF0upozFKhTtXM=", + "owner": "divnix", + "repo": "nosys", + "rev": "2d0d5207f6a230e9d0f660903f8db9807b54814f", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "nosys", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "std": "std" + } + }, + "std": { + "inputs": { + "arion": [ + "std", + "blank" + ], + "blank": "blank", + "devshell": "devshell", + "dmerge": "dmerge", + "flake-utils": "flake-utils", + "incl": "incl", + "makes": [ + "std", + "blank" + ], + "mdbook-kroki-preprocessor": "mdbook-kroki-preprocessor", + "microvm": [ + "std", + "blank" + ], + "n2c": "n2c", + "nixago": "nixago", + "nixpkgs": [ + "nixpkgs" + ], + "nosys": "nosys", + "yants": "yants" + }, + "locked": { + "lastModified": 1669064207, + "narHash": "sha256-9wdHm7AInbl4CU5hEqC4ekvWBOpj9kqR229V+tAI7B4=", + "owner": "divnix", + "repo": "std", + "rev": "b1d379f97ace2e92d214f71941920beb67afed1c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "std", + "type": "github" + } + }, + "yants": { + "inputs": { + "nixpkgs": [ + "std", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1667096281, + "narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=", + "owner": "divnix", + "repo": "yants", + "rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c", + "type": "github" + }, + "original": { + "owner": "divnix", + "repo": "yants", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 18d87c1..63ac126 100644 --- a/flake.nix +++ b/flake.nix @@ -1,52 +1,75 @@ { description = "A kick ass library to extend your DevOS experience"; - inputs = - { - nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; - }; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + std.url = "github:divnix/std"; + std.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + std, + ... + } @ inputs: let + l = nixpkgs.lib // builtins // self.lib; - outputs = - { self - , nixpkgs - , ... - }@inputs: - let - # Unofficial Flakes Roadmap - Polyfills - # .. see: https://demo.hedgedoc.org/s/_W6Ve03GK# - # .. also: /ufr-polyfills - # Super Stupid Flakes (ssf) / System As an Input - Style: - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; - ufrContract = import ./ufr-polyfills/ufrContract.nix; - # Dependency Groups - Style - # .. we hope you like this style. - # .. it's adopted by a growing number of projects. - # Please consider adopting it if you want to help to improve flakes. + # exports have no system, pick one + exports' = "x86_64-linux"; + exports = inputs.self."${exports'}"; + in + std.growOn { + inherit inputs; - makeExtLib = pkgSet: path: { pkgSetUtils ? "${pkgSet}-utils" }@attrs: [ - (import ./src/overlay.nix pkgSet path attrs) - ] ++ nixpkgs.lib.optionals - (builtins.pathExists "${path}/overlay.nix") - [ "${path}/overlay.nix" ]; - in - { - lib.makeExtLib = makeExtLib; + cellsFrom = ./cells; - # what you came for ... - packages = ufrContract supportedSystems ./. inputs self; + cellBlocks = with std.blockTypes; [ + # builders to make package sets + (functions "builders") - overlays = { + # devshells can be entered + (devshells "devshells") - minecraft-mods = makeExtLib "minecraft-mods" ./src/pkgs/misc/minecraft-mods { }; + # library holds shared knowledge made code + (functions "lib") - papermc = makeExtLib "papermc-pkgs" ./src/pkgs/games/papermc { pkgSetUtils = "papermc-utils"; }; + # packages can be installed + (functions "packages") - python3Packages = makeExtLib "python3Packages" ./src/pkgs/development/python-modules { }; + # overlays + (functions "overlays") - vimPlugins = makeExtLib "vimPlugins" ./src/pkgs/misc/vim-plugins { pkgSetUtils = "vimUtils"; }; + # tests + (functions "tests") + ]; + } { + devShells = std.harvest self ["_automation" "devshells"]; - vscode-extensions = makeExtLib "vscode-extensions" ./src/pkgs/misc/vscode-extensions { pkgSetUtils = "vscode-utils"; }; + # get all cells with `lib` target, and merge it into a single attrset + lib = let + # bootstrapping lib from cells.std.lib + std.lib = inputs.std.harvest self ["std" "lib"]; + in + std.lib."${exports'}".trimBy exports ["lib"]; - }; + # overlays + overlays = l.std.trim exports ["overlays"]; }; + + # --- Flake Local Nix Configuration ---------------------------- + # TODO: adopt spongix + nixConfig = { + extra-substituters = [ + "https://cache.nixos.org" + "https://nix-community.cachix.org" + "https://fog.cachix.org" + ]; + extra-trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "fog.cachix.org-1:FAxiA6qMLoXEUdEq+HaT24g1MjnxdfygrbrLDBp6U/s=" + ]; + }; + # -------------------------------------------------------------- } diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 34dcbf8..0000000 --- a/shell.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ self, inputs, ... }: -{ - externalModules = with inputs; [ - bud.devshellModules.bud - ]; -} diff --git a/src/default.nix b/src/default.nix deleted file mode 100644 index 32dab1a..0000000 --- a/src/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ lib, filterSources, pkgBuilder, pkgSet }: - -sources: { prefix ? "", ... }@overrides: - -let - - filterSources' = overrides.filterSources or filterSources; - - pkgBuilder' = overrides.pkgBuilder or pkgBuilder; - - pkgSources = filterSources' prefix sources; - - pkgBuilderWithPrefix = pkgBuilder' prefix; - - pkgSet' = lib.mapAttrs' pkgBuilderWithPrefix pkgSources; - -in pkgSet // pkgSet' diff --git a/src/lib/attrsets.nix b/src/lib/attrsets.nix deleted file mode 100644 index 745fbbb..0000000 --- a/src/lib/attrsets.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ lib, attrsets }: attrsets // { - dontFilterSources = _: sources: sources; - - filterSources = prefix: sources: lib.mapAttrs' - (name: value: - lib.nameValuePair - (lib.removePrefix prefix name) - value) - (lib.filterAttrs - (n: v: lib.hasPrefix prefix n) - sources); -} \ No newline at end of file diff --git a/src/overlay.nix b/src/overlay.nix deleted file mode 100644 index b06baa6..0000000 --- a/src/overlay.nix +++ /dev/null @@ -1,30 +0,0 @@ -pkgSet: path: { pkgSetUtils ? "${pkgSet}-utils" }: - -final: prev: -{ - "${pkgSetUtils}" = final.callPackage "${path}/utils.nix" { - pkgSet = prev."${pkgSet}" or { }; - pkgSetUtils = prev."${pkgSetUtils}" or { }; - }; - - lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { - attrsets = import ./lib/attrsets.nix { - inherit lib; - inherit (lprev) attrsets; - }; - - "${pkgSet}" = import "${path}/lib.nix" { inherit lib; }; - - inherit (lfinal.attrsets) - dontFilterSources - filterSources - ; - }); - - "${pkgSet}-builder" = import ./. { - inherit (final) lib; - inherit (final.lib."${pkgSet}") filterSources; - inherit (final."${pkgSetUtils}") pkgBuilder; - pkgSet = prev."${pkgSet}" or { }; - }; -} diff --git a/src/pkgs/development/python-modules/lib.nix b/src/pkgs/development/python-modules/lib.nix deleted file mode 100644 index abda28f..0000000 --- a/src/pkgs/development/python-modules/lib.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ lib }: { - inherit (lib) filterSources; -} diff --git a/src/pkgs/development/python-modules/utils.nix b/src/pkgs/development/python-modules/utils.nix deleted file mode 100644 index 8d1af22..0000000 --- a/src/pkgs/development/python-modules/utils.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ lib, pkgSet, pkgSetUtils, python3Packages }: -let - meta = { }; -in pkgSetUtils // { - pkgBuilder = prefix: pname: { meta ? pkgSetUtils.meta or meta, doCheck ? false, ... }@source: let - source' = builtins.removeAttrs source [ "pname" ]; - package = python3Packages.buildPythonPackage (source' // { - inherit pname; - doCheck = false; - }); - in lib.nameValuePair pname package; -} diff --git a/src/pkgs/games/papermc/lib.nix b/src/pkgs/games/papermc/lib.nix deleted file mode 100644 index 2b94e8e..0000000 --- a/src/pkgs/games/papermc/lib.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ lib }: { - filterSources = prefix: lib.filterAttrs (n: v: lib.hasPrefix prefix n); -} diff --git a/src/pkgs/games/papermc/overlay.nix b/src/pkgs/games/papermc/overlay.nix deleted file mode 100644 index cc51d1d..0000000 --- a/src/pkgs/games/papermc/overlay.nix +++ /dev/null @@ -1,8 +0,0 @@ -final: prev: -{ - lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { - inherit (lib.papermc) - mapMcJreVersion - ; - }); -} diff --git a/src/pkgs/games/papermc/utils.nix b/src/pkgs/games/papermc/utils.nix deleted file mode 100644 index 87e5751..0000000 --- a/src/pkgs/games/papermc/utils.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib -, pkgSet -, pkgSetUtils -, papermc - -, jre8 -, jre_headless -, adoptopenjdk-jre-openj9-bin-16 -, javaPackages -}: pkgSetUtils // rec { - # based on https://www.creeperhost.net/wiki/books/minecraft-java-edition/page/changing-java-versions - mapMcJreVersion = mcVer: let - isMcVer = mcVer': builtins.compareVersions mcVer mcVer' == -1; - in - if isMcVer "1.17" then jre8 - else if isMcVer "1.18" then adoptopenjdk-jre-openj9-bin-16 - else if isMcVer "1.19" then javaPackages.compiler.openjdk17.headless - else jre_headless; - - pkgBuilder = - prefix: name: - { src - , pname - , version - - , mcVer - - , meta ? pkgSetUtils.meta or papermc.meta - , ... - }@source: - let - source' = builtins.removeAttrs source - [ - "pname" - "version" - ]; - papermc' = (papermc.override { - jre = mapMcJreVersion mcVer; - }).overrideAttrs (_: source' // { - passthru.mcVer = mcVer; - version = "${mcVer}r${version}"; - }); - in lib.nameValuePair name papermc'; -} diff --git a/src/pkgs/misc/minecraft-mods/default.nix b/src/pkgs/misc/minecraft-mods/default.nix deleted file mode 100644 index 0ad0570..0000000 --- a/src/pkgs/misc/minecraft-mods/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib }: { - inherit (lib) filterSources; - - isJar = lib.hasSuffix ".jar"; -} diff --git a/src/pkgs/misc/minecraft-mods/lib.nix b/src/pkgs/misc/minecraft-mods/lib.nix deleted file mode 100644 index 0ad0570..0000000 --- a/src/pkgs/misc/minecraft-mods/lib.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ lib }: { - inherit (lib) filterSources; - - isJar = lib.hasSuffix ".jar"; -} diff --git a/src/pkgs/misc/minecraft-mods/overlay.nix b/src/pkgs/misc/minecraft-mods/overlay.nix deleted file mode 100644 index 169997f..0000000 --- a/src/pkgs/misc/minecraft-mods/overlay.nix +++ /dev/null @@ -1,8 +0,0 @@ -final: prev: -{ - lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { - inherit (lib.minecraft-mods) - isJar - ; - }); -} diff --git a/src/pkgs/misc/minecraft-mods/utils.nix b/src/pkgs/misc/minecraft-mods/utils.nix deleted file mode 100644 index d56797c..0000000 --- a/src/pkgs/misc/minecraft-mods/utils.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ stdenv -, lib -, pkgSet -, pkgSetUtils -, fd -, unzip -}: -let - jars' = [ - ".*-SNAPSHOT.jar" - ''.*[.*|\d+\.\d+\.\d+].jar'' - ".*[fabric|forge].*.jar" - ]; - - meta' = { }; -in pkgSetUtils // { - pkgBuilder = - prefix: modName: - { src - , version - - , mcVer ? "any" - - , modId ? modName - - , meta ? pkgSetUtils.meta or meta' - , jars ? pkgSetUtils.jars or jars' - , ... - }@source: - let - dontUnpack = lib.isJar src.name; - mod = stdenv.mkDerivation { - inherit src version dontUnpack; - - pname = "${prefix}-${modName}"; - - passthru = { inherit mcVer modId; }; - - nativeBuildInputs = [ fd ] - ++ lib.optionals (!dontUnpack) [ unzip ]; - - unpackPhase = lib.optionalString (!dontUnpack) '' - unzip $src - ''; - - installPhase = '' - mkdir -p $out/share/java - ${if dontUnpack - then "ln -s $src ." - else "fd '.*dev|sources.jar' -X rm"} - ${lib.concatMapStrings - (e: '' - fd '${e}' -x mv {} $out/share/java/${modName}-$version.jar - '') - jars} - ''; - }; - in lib.nameValuePair modName mod; -} diff --git a/src/pkgs/misc/vim-plugins/lib.nix b/src/pkgs/misc/vim-plugins/lib.nix deleted file mode 100644 index abda28f..0000000 --- a/src/pkgs/misc/vim-plugins/lib.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ lib }: { - inherit (lib) filterSources; -} diff --git a/src/pkgs/misc/vim-plugins/utils.nix b/src/pkgs/misc/vim-plugins/utils.nix deleted file mode 100644 index 5bb8e5b..0000000 --- a/src/pkgs/misc/vim-plugins/utils.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ lib, pkgSet, pkgSetUtils, vim }: -let - meta = { }; -in pkgSetUtils // { - pkgBuilder = prefix: pname: { meta ? pkgSetUtils.meta or meta, ... }@source: let - source' = builtins.removeAttrs source [ "pname" ]; - plugin = pkgSetUtils.buildVimPluginFrom2Nix (source' // { inherit pname; }); - in lib.nameValuePair pname plugin; -} diff --git a/src/pkgs/misc/vscode-extensions/lib.nix b/src/pkgs/misc/vscode-extensions/lib.nix deleted file mode 100644 index 958e23d..0000000 --- a/src/pkgs/misc/vscode-extensions/lib.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ lib }: rec { - inherit (lib) filterSources; - - filterSources' = prefix: sources: - let - sources' = filterSources prefix sources; - publishers = lib.groupBy - (source: source.publisher) - (builtins.attrValues sources'); - in publishers; -} diff --git a/src/pkgs/misc/vscode-extensions/utils.nix b/src/pkgs/misc/vscode-extensions/utils.nix deleted file mode 100644 index da0fec8..0000000 --- a/src/pkgs/misc/vscode-extensions/utils.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ lib, pkgSet, pkgSetUtils, vscode, libarchive }: -let - meta' = { inherit (vscode) platforms; }; -in pkgSetUtils // rec { - pkgBuilder = - prefix: name': - { src - , pname - , version - - , name - , publisher - - , meta ? pkgSetUtils.meta or meta' - , ... - }@source: - let - source' = builtins.removeAttrs source - [ - "src" - "pname" - "name" - "publisher" - "version" - ]; - ext = pkgSetUtils.buildVscodeMarketplaceExtension (source' // { - vsix = src; - mktplcRef = { inherit version name publisher; }; - buildInputs = [ libarchive ]; - unpackPhase = '' - bsdtar xvf "$src" --strip-components=1 'extension/*' - ''; - }); - in lib.nameValuePair (lib.toLower name') ext; - - pkgBuilder' = prefix: publisher: sources: - let - pkgSet' = pkgSet."${publisher}" or { }; - exts = lib.foldl' (r: e: - let - inherit (pkgBuilder prefix e.name e) name value; - in r // { "${name}" = value; } - ) { } sources; - in lib.nameValuePair (lib.toLower publisher) (pkgSet' // exts); -} \ No newline at end of file diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..8feeed2 --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2022 The Standard Authors +# SPDX-FileCopyrightText: 2022 Kevin Amado +# +# SPDX-License-Identifier: Unlicense + +# One CLI to format the code tree - https://github.com/numtide/treefmt + +[formatter.nix] +command = "alejandra" +includes = ["*.nix"] diff --git a/ufr-polyfills/UnofficialFlakesRoadmap.md b/ufr-polyfills/UnofficialFlakesRoadmap.md deleted file mode 100644 index 4645d5f..0000000 --- a/ufr-polyfills/UnofficialFlakesRoadmap.md +++ /dev/null @@ -1,6 +0,0 @@ -# Hey! - -This project is commited to the [Unofficial Flakes Roadmap (ufr)](https://demo.hedgedoc.org/s/_W6Ve03GK#). - - -_The future of flakes is bright again._ diff --git a/ufr-polyfills/eachSystem.nix b/ufr-polyfills/eachSystem.nix deleted file mode 100644 index 6c70788..0000000 --- a/ufr-polyfills/eachSystem.nix +++ /dev/null @@ -1,11 +0,0 @@ -# Builds a map from value to =value for each system. -# .. adopted from: https://github.com/numtide/flake-utils -# -systems: f: -let - op = attrs: system: - attrs // { - "${system}" = f system; - }; -in -builtins.foldl' op { } systems diff --git a/ufr-polyfills/flake.lock.nix b/ufr-polyfills/flake.lock.nix deleted file mode 100644 index 372dcd3..0000000 --- a/ufr-polyfills/flake.lock.nix +++ /dev/null @@ -1,114 +0,0 @@ -# Adapted from https://github.com/edolstra/flake-compat/blob/master/default.nix -# -# This version only gives back the inputs. In that mode, flake becomes little -# more than a niv replacement. -src: -let - lockFilePath = src + "/flake.lock"; - - lockFile = builtins.fromJSON (builtins.readFile lockFilePath); - - # Emulate builtins.fetchTree - # - # TODO: only implement polyfill if the builtin doesn't exist? - fetchTree = - info: - if info.type == "github" then - { - outPath = fetchTarball { - url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; - sha256 = info.narHash; - }; - inherit (info) rev; - shortRev = builtins.substring 0 7 info.rev; - inherit (info) lastModified; - inherit (info) narHash; - } - else if info.type == "git" then - { - outPath = - builtins.fetchGit - ({ inherit (info) url; sha256 = info.narHash; } - // (if info ? rev then { inherit (info) rev; } else { }) - // (if info ? ref then { inherit (info) ref; } else { }) - ); - inherit (info) lastModified; - inherit (info) narHash; - } // (if info ? rev then { - inherit (info) rev; - shortRev = builtins.substring 0 7 info.rev; - } else { }) - else if info.type == "path" then - { - outPath = builtins.path { inherit (info) path; }; - inherit (info) narHash; - } - else if info.type == "tarball" then - { - outPath = fetchTarball { - inherit (info) url; - sha256 = info.narHash; - }; - inherit (info) narHash; - } - else if info.type == "gitlab" then - { - inherit (info) rev narHash lastModified; - outPath = fetchTarball { - url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; - sha256 = info.narHash; - }; - shortRev = builtins.substring 0 7 info.rev; - } - else - # FIXME: add Mercurial, tarball inputs. - throw "flake input has unsupported input type '${info.type}'"; - - allNodes = - builtins.mapAttrs - (key: node: - let - sourceInfo = - if key == lockFile.root - then { } - else fetchTree (node.info or { } // removeAttrs node.locked [ "dir" ]); - - inputs = builtins.mapAttrs - (inputName: inputSpec: allNodes."${resolveInput inputSpec}") - (node.inputs or { }); - - # Resolve a input spec into a node name. An input spec is - # either a node name, or a 'follows' path from the root - # node. - resolveInput = inputSpec: - if builtins.isList inputSpec - then getInputByPath lockFile.root inputSpec - else inputSpec; - - # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the - # root node, returning the final node. - getInputByPath = nodeName: path: - if path == [ ] - then nodeName - else - getInputByPath - # Since this could be a 'follows' input, call resolveInput. - (resolveInput lockFile.nodes."${nodeName}".inputs."${builtins.head path}") - (builtins.tail path); - - result = sourceInfo // { inherit inputs; inherit sourceInfo; }; - in - if node.flake or true then - result - else - sourceInfo - ) - lockFile.nodes; - - result = - if lockFile.version >= 5 && lockFile.version <= 7 - then allNodes."${lockFile.root}".inputs - else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}"; - -in -result diff --git a/ufr-polyfills/ufrContract.nix b/ufr-polyfills/ufrContract.nix deleted file mode 100644 index 0f411bc..0000000 --- a/ufr-polyfills/ufrContract.nix +++ /dev/null @@ -1,11 +0,0 @@ -let - eachSystem = import ./eachSystem.nix; -in - -supportedSystems: -imprt: inputs: self: -eachSystem supportedSystems (system: - import imprt { - inherit inputs system self; # The super stupid flakes contract `{ inputs, system }` - } -)