├── LICENSE ├── README.md ├── bud ├── default.nix └── vscode-ext-prefetch.bash ├── default.nix ├── flake.lock ├── flake.nix ├── shell.nix ├── src ├── default.nix ├── lib │ └── attrsets.nix ├── overlay.nix └── pkgs │ ├── development │ └── python-modules │ │ ├── lib.nix │ │ └── utils.nix │ ├── games │ └── papermc │ │ ├── lib.nix │ │ ├── overlay.nix │ │ └── utils.nix │ └── misc │ ├── minecraft-mods │ ├── default.nix │ ├── lib.nix │ ├── overlay.nix │ └── utils.nix │ ├── vim-plugins │ ├── lib.nix │ └── utils.nix │ └── vscode-extensions │ ├── lib.nix │ └── utils.nix └── ufr-polyfills ├── UnofficialFlakesRoadmap.md ├── eachSystem.nix ├── flake.lock.nix └── ufrContract.nix /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 DivNix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![MIT License](https://img.shields.io/github/license/divnix/devos)][mit] [![NixOS](https://img.shields.io/badge/NixOS-release--21.11-blue.svg?style=flat&logo=NixOS&logoColor=white)](https://nixos.org) 2 | 3 | # Introduction 4 | 5 | This is a kick ass library to dominate your Extensions (with [DevOS][devos]). 6 | 7 | Currently [VS Code] extensions and some other package sets are supported. See also [flake.nix](./flake.nix). 8 | 9 | # Usage 10 | 11 | For now, let's use [VS Code] as an example. 12 | 13 | Within `devos` itself, you can use as follow: 14 | 15 | In `flake.nix`: 16 | ```nix 17 | { 18 | inputs.devos-ext-lib.url = "github:divnix/devos-ext-lib"; 19 | outputs = inputs@{ devos-ext-lib, ... }: digga.lib.mkFlake { 20 | channels.nixos.overlays = [ devos-ext-lib.overlays.vscode ]; 21 | }; 22 | } 23 | ``` 24 | 25 | In `pkgs/default.nix`: 26 | ```nix 27 | final: prev: 28 | let 29 | sources = callPackage ./_sources/generated.nix { }; 30 | in { 31 | vscode-extensions = final.vscode-extensions-builder sources { 32 | # a function to merge previous extensions from a publisher 33 | # with new ones from `sources` 34 | # note: publisher and extension name are automatically converted 35 | # to lower case 36 | pkgBuilder = final.vscode-utils.pkgBuilder'; 37 | 38 | # a function that filters the sources by a prefix 39 | # and group them by their publishers (i.e. "${publisher}.${extension-name}") 40 | filterSources = final.lib.vscode-extensions.filterSources'; 41 | 42 | # A typical nvfetcher toml: 43 | # [vscode-extensions-paulmolluzzo-convert-css-in-js] 44 | # src.manual = "0.3.0" 45 | # fetch.url = "https://open-vsx.org/api/paulmolluzzo/convert-css-in-js/0.3.0/file/paulmolluzzo.convert-css-in-js-0.3.0.vsix" 46 | # passthru = { publisher = "paulmolluzzo", name = "convert-css-in-js", description = "Convert kebab-case CSS to camelCase CSS and vice versa", license = "MIT" } 47 | # 48 | prefix = "vscode-extensions"; 49 | }; 50 | } 51 | ``` 52 | 53 | It simply map through sources for VS Code extensions with `pkgBuilder`, 54 | and you can override each extensions using //. 55 | 56 | You can now refer to them as `pkgs.vscode-extensions.${publisher}.${extension-name}`, 57 | such as `pkgs.vscode-extensions.paulmolluzzo.convert-css-in-js`. 58 | 59 | ## Metadata 60 | 61 | For my personal use case, I use [openvsx-updater](https://github.com/danielphan2003/nixpkgs/blob/main/cells/nixpkgs/cli/updaters/openvsx.bash) 62 | and more generally [danielphan2003/nixpkgs](https://github.com/danielphan2003/nixpkgs) to generate metadata automatically. 63 | 64 | It uses GitHub Actions to fetch metadata from [OpenVSX], and [nvfetcher] 65 | to get the sources and pass through the metadata for [VS Code] extensions. 66 | 67 | Note that [VS Marketplace] extensions does not have a clear API for metadata extraction. 68 | As a result, only [OpenVSX] ones are able to do so. 69 | 70 | ## TODOs: 71 | - [ ] Documentation: 72 | - [ ] [minecraft-mods](./src/pkgs/misc/minecraft-mods) 73 | - [ ] [papermc](./src/pkgs/games/papermc) 74 | - [ ] [python3Packages](./src/pkgs/development/python-modules) 75 | - [ ] [vimPlugins](./src/pkgs/misc/vim-plugins) 76 | - [ ] [vscode-extensions](./src/pkgs/misc/vscode-extensions) 77 | - [ ] Simplify API. 78 | - [ ] Overlays or just plain `packages.${...}`? 79 | - [ ] Tests for packaging extensions. 80 | 81 | ## Shoulders 82 | This work does not reinvent the wheel. It stands on the [shoulders of the 83 | following giants][giants]: 84 | 85 | ### :onion: — like the layers of an onion 86 | - [`divnix/devos`][devos] 87 | - [`gytis-ivaskevicius/flake-utils-plus`][fup] 88 | - [`numtide/flake-utils`][fu] 89 | 90 | ### :family: — like family 91 | - [`numtide/devshell`][devshell] 92 | - [`berberman/nvfetcher`][nvfetcher] 93 | - [`NixOS/nixpkgs`][nixpkgs] 94 | 95 | :heart: 96 | 97 | [mit]: https://mit-license.org 98 | 99 | [devos]: https://github.com/divnix/devos 100 | 101 | [VS Code]: https://code.visualstudio.com 102 | [VS Marketplace]: https://marketplace.visualstudio.com/vscode 103 | [OpenVSX]: https://open-vsx.org 104 | 105 | [fu]: https://github.com/numtide/flake-utils 106 | [fup]: https://github.com/gytis-ivaskevicius/flake-utils-plus 107 | [giants]: https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants 108 | [devshell]: https://github.com/numtide/devshell 109 | [nixpkgs]: https://github.com/NixOS/nixpkgs 110 | [nvfetcher]: https://github.com/berberman/nvfetcher 111 | -------------------------------------------------------------------------------- /bud/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs, lib, budUtils, ... }: { 2 | bud.cmds = with pkgs; { 3 | vscode-ext-prefetch = { 4 | writer = budUtils.writeBashWithPaths [ curl jq ]; 5 | synopsis = "vscode-ext-prefetch"; 6 | help = "Prefetch meta for vscode extensions"; 7 | script = ./vscode-ext-prefetch.bash; 8 | }; 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /bud/vscode-ext-prefetch.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | id="$1" 4 | query="$(curl -s https://open-vsx.org/api/$id)" 5 | type="openvsx" 6 | namespace="$(echo $query | jq --raw-output '.namespace')" 7 | if [ "$namespace" = "null" ]; then exit 1; fi 8 | extension="$(echo $query | jq --raw-output '.name')" 9 | license="$(echo $query | jq --raw-output '.license')" 10 | repo="$(echo $query | jq --raw-output '.repository')" 11 | description="$(echo $query | jq --raw-output '.description')" 12 | echo "[$extension]" 13 | echo "src.$type = \"$namespace.$extension\"" 14 | echo "fetch.$type = \"$namespace.$extension\"" 15 | echo "passthru = { license = \"${license,,}\", homepage = \"$repo\", description = \"$description\" }" 16 | echo "" 17 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { inputs, self, system ? builtins.currentSystem }: 2 | let 3 | flatten' = builtins.foldl' (a: b: a ++ b) [ ]; 4 | 5 | pkgs = import inputs.nixpkgs { 6 | inherit system; 7 | config = { }; 8 | overlays = flatten' (builtins.attrValues { 9 | inherit (self.overlays) 10 | minecraft-mods 11 | papermc 12 | python3Packages 13 | vimPlugins 14 | vscode-extensions 15 | ; 16 | }); 17 | }; 18 | in 19 | { 20 | inherit (pkgs) 21 | lib 22 | 23 | minecraft-mods-builder 24 | minecraft-utils 25 | 26 | papermc-pkgs-builder 27 | papermc-utils 28 | 29 | python3Packages-builder 30 | python3Packages-utils 31 | 32 | vimPlugins-builder 33 | vimUtils 34 | 35 | vscode-extensions-builder 36 | vscode-utils 37 | ; 38 | } 39 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "nixpkgs": { 4 | "locked": { 5 | "lastModified": 1638330963, 6 | "narHash": "sha256-Xp5YJPzYImZCRDjXqc5STDey/i8ikWa6Y5tADpI5+5I=", 7 | "owner": "nixos", 8 | "repo": "nixpkgs", 9 | "rev": "c7b4ee906c957538e65599e6c43046f2a3c6fb97", 10 | "type": "github" 11 | }, 12 | "original": { 13 | "owner": "nixos", 14 | "ref": "release-21.11", 15 | "repo": "nixpkgs", 16 | "type": "github" 17 | } 18 | }, 19 | "root": { 20 | "inputs": { 21 | "nixpkgs": "nixpkgs" 22 | } 23 | } 24 | }, 25 | "root": "root", 26 | "version": 7 27 | } 28 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "A kick ass library to extend your DevOS experience"; 3 | 4 | inputs = 5 | { 6 | nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; 7 | }; 8 | 9 | outputs = 10 | { self 11 | , nixpkgs 12 | , ... 13 | }@inputs: 14 | let 15 | # Unofficial Flakes Roadmap - Polyfills 16 | # .. see: https://demo.hedgedoc.org/s/_W6Ve03GK# 17 | # .. also: /ufr-polyfills 18 | # Super Stupid Flakes (ssf) / System As an Input - Style: 19 | supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; 20 | ufrContract = import ./ufr-polyfills/ufrContract.nix; 21 | # Dependency Groups - Style 22 | # .. we hope you like this style. 23 | # .. it's adopted by a growing number of projects. 24 | # Please consider adopting it if you want to help to improve flakes. 25 | 26 | makeExtLib = pkgSet: path: { pkgSetUtils ? "${pkgSet}-utils" }@attrs: [ 27 | (import ./src/overlay.nix pkgSet path attrs) 28 | ] ++ nixpkgs.lib.optionals 29 | (builtins.pathExists "${path}/overlay.nix") 30 | [ "${path}/overlay.nix" ]; 31 | in 32 | { 33 | lib.makeExtLib = makeExtLib; 34 | 35 | # what you came for ... 36 | packages = ufrContract supportedSystems ./. inputs self; 37 | 38 | overlays = { 39 | 40 | minecraft-mods = makeExtLib "minecraft-mods" ./src/pkgs/misc/minecraft-mods { }; 41 | 42 | papermc = makeExtLib "papermc-pkgs" ./src/pkgs/games/papermc { pkgSetUtils = "papermc-utils"; }; 43 | 44 | python3Packages = makeExtLib "python3Packages" ./src/pkgs/development/python-modules { }; 45 | 46 | vimPlugins = makeExtLib "vimPlugins" ./src/pkgs/misc/vim-plugins { pkgSetUtils = "vimUtils"; }; 47 | 48 | vscode-extensions = makeExtLib "vscode-extensions" ./src/pkgs/misc/vscode-extensions { pkgSetUtils = "vscode-utils"; }; 49 | 50 | }; 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | { self, inputs, ... }: 2 | { 3 | externalModules = with inputs; [ 4 | bud.devshellModules.bud 5 | ]; 6 | } 7 | -------------------------------------------------------------------------------- /src/default.nix: -------------------------------------------------------------------------------- 1 | { lib, filterSources, pkgBuilder, pkgSet }: 2 | 3 | sources: { prefix ? "", ... }@overrides: 4 | 5 | let 6 | 7 | filterSources' = overrides.filterSources or filterSources; 8 | 9 | pkgBuilder' = overrides.pkgBuilder or pkgBuilder; 10 | 11 | pkgSources = filterSources' prefix sources; 12 | 13 | pkgBuilderWithPrefix = pkgBuilder' prefix; 14 | 15 | pkgSet' = lib.mapAttrs' pkgBuilderWithPrefix pkgSources; 16 | 17 | in pkgSet // pkgSet' 18 | -------------------------------------------------------------------------------- /src/lib/attrsets.nix: -------------------------------------------------------------------------------- 1 | { lib, attrsets }: attrsets // { 2 | dontFilterSources = _: sources: sources; 3 | 4 | filterSources = prefix: sources: lib.mapAttrs' 5 | (name: value: 6 | lib.nameValuePair 7 | (lib.removePrefix prefix name) 8 | value) 9 | (lib.filterAttrs 10 | (n: v: lib.hasPrefix prefix n) 11 | sources); 12 | } -------------------------------------------------------------------------------- /src/overlay.nix: -------------------------------------------------------------------------------- 1 | pkgSet: path: { pkgSetUtils ? "${pkgSet}-utils" }: 2 | 3 | final: prev: 4 | { 5 | "${pkgSetUtils}" = final.callPackage "${path}/utils.nix" { 6 | pkgSet = prev."${pkgSet}" or { }; 7 | pkgSetUtils = prev."${pkgSetUtils}" or { }; 8 | }; 9 | 10 | lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { 11 | attrsets = import ./lib/attrsets.nix { 12 | inherit lib; 13 | inherit (lprev) attrsets; 14 | }; 15 | 16 | "${pkgSet}" = import "${path}/lib.nix" { inherit lib; }; 17 | 18 | inherit (lfinal.attrsets) 19 | dontFilterSources 20 | filterSources 21 | ; 22 | }); 23 | 24 | "${pkgSet}-builder" = import ./. { 25 | inherit (final) lib; 26 | inherit (final.lib."${pkgSet}") filterSources; 27 | inherit (final."${pkgSetUtils}") pkgBuilder; 28 | pkgSet = prev."${pkgSet}" or { }; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /src/pkgs/development/python-modules/lib.nix: -------------------------------------------------------------------------------- 1 | { lib }: { 2 | inherit (lib) filterSources; 3 | } 4 | -------------------------------------------------------------------------------- /src/pkgs/development/python-modules/utils.nix: -------------------------------------------------------------------------------- 1 | { lib, pkgSet, pkgSetUtils, python3Packages }: 2 | let 3 | meta = { }; 4 | in pkgSetUtils // { 5 | pkgBuilder = prefix: pname: { meta ? pkgSetUtils.meta or meta, doCheck ? false, ... }@source: let 6 | source' = builtins.removeAttrs source [ "pname" ]; 7 | package = python3Packages.buildPythonPackage (source' // { 8 | inherit pname; 9 | doCheck = false; 10 | }); 11 | in lib.nameValuePair pname package; 12 | } 13 | -------------------------------------------------------------------------------- /src/pkgs/games/papermc/lib.nix: -------------------------------------------------------------------------------- 1 | { lib }: { 2 | filterSources = prefix: lib.filterAttrs (n: v: lib.hasPrefix prefix n); 3 | } 4 | -------------------------------------------------------------------------------- /src/pkgs/games/papermc/overlay.nix: -------------------------------------------------------------------------------- 1 | final: prev: 2 | { 3 | lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { 4 | inherit (lib.papermc) 5 | mapMcJreVersion 6 | ; 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /src/pkgs/games/papermc/utils.nix: -------------------------------------------------------------------------------- 1 | { lib 2 | , pkgSet 3 | , pkgSetUtils 4 | , papermc 5 | 6 | , jre8 7 | , jre_headless 8 | , adoptopenjdk-jre-openj9-bin-16 9 | , javaPackages 10 | }: pkgSetUtils // rec { 11 | # based on https://www.creeperhost.net/wiki/books/minecraft-java-edition/page/changing-java-versions 12 | mapMcJreVersion = mcVer: let 13 | isMcVer = mcVer': builtins.compareVersions mcVer mcVer' == -1; 14 | in 15 | if isMcVer "1.17" then jre8 16 | else if isMcVer "1.18" then adoptopenjdk-jre-openj9-bin-16 17 | else if isMcVer "1.19" then javaPackages.compiler.openjdk17.headless 18 | else jre_headless; 19 | 20 | pkgBuilder = 21 | prefix: name: 22 | { src 23 | , pname 24 | , version 25 | 26 | , mcVer 27 | 28 | , meta ? pkgSetUtils.meta or papermc.meta 29 | , ... 30 | }@source: 31 | let 32 | source' = builtins.removeAttrs source 33 | [ 34 | "pname" 35 | "version" 36 | ]; 37 | papermc' = (papermc.override { 38 | jre = mapMcJreVersion mcVer; 39 | }).overrideAttrs (_: source' // { 40 | passthru.mcVer = mcVer; 41 | version = "${mcVer}r${version}"; 42 | }); 43 | in lib.nameValuePair name papermc'; 44 | } 45 | -------------------------------------------------------------------------------- /src/pkgs/misc/minecraft-mods/default.nix: -------------------------------------------------------------------------------- 1 | { lib }: { 2 | inherit (lib) filterSources; 3 | 4 | isJar = lib.hasSuffix ".jar"; 5 | } 6 | -------------------------------------------------------------------------------- /src/pkgs/misc/minecraft-mods/lib.nix: -------------------------------------------------------------------------------- 1 | { lib }: { 2 | inherit (lib) filterSources; 3 | 4 | isJar = lib.hasSuffix ".jar"; 5 | } 6 | -------------------------------------------------------------------------------- /src/pkgs/misc/minecraft-mods/overlay.nix: -------------------------------------------------------------------------------- 1 | final: prev: 2 | { 3 | lib = prev.lib.extend (lfinal: lprev: let lib = lfinal; in { 4 | inherit (lib.minecraft-mods) 5 | isJar 6 | ; 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /src/pkgs/misc/minecraft-mods/utils.nix: -------------------------------------------------------------------------------- 1 | { stdenv 2 | , lib 3 | , pkgSet 4 | , pkgSetUtils 5 | , fd 6 | , unzip 7 | }: 8 | let 9 | jars' = [ 10 | ".*-SNAPSHOT.jar" 11 | ''.*[.*|\d+\.\d+\.\d+].jar'' 12 | ".*[fabric|forge].*.jar" 13 | ]; 14 | 15 | meta' = { }; 16 | in pkgSetUtils // { 17 | pkgBuilder = 18 | prefix: modName: 19 | { src 20 | , version 21 | 22 | , mcVer ? "any" 23 | 24 | , modId ? modName 25 | 26 | , meta ? pkgSetUtils.meta or meta' 27 | , jars ? pkgSetUtils.jars or jars' 28 | , ... 29 | }@source: 30 | let 31 | dontUnpack = lib.isJar src.name; 32 | mod = stdenv.mkDerivation { 33 | inherit src version dontUnpack; 34 | 35 | pname = "${prefix}-${modName}"; 36 | 37 | passthru = { inherit mcVer modId; }; 38 | 39 | nativeBuildInputs = [ fd ] 40 | ++ lib.optionals (!dontUnpack) [ unzip ]; 41 | 42 | unpackPhase = lib.optionalString (!dontUnpack) '' 43 | unzip $src 44 | ''; 45 | 46 | installPhase = '' 47 | mkdir -p $out/share/java 48 | ${if dontUnpack 49 | then "ln -s $src ." 50 | else "fd '.*dev|sources.jar' -X rm"} 51 | ${lib.concatMapStrings 52 | (e: '' 53 | fd '${e}' -x mv {} $out/share/java/${modName}-$version.jar 54 | '') 55 | jars} 56 | ''; 57 | }; 58 | in lib.nameValuePair modName mod; 59 | } 60 | -------------------------------------------------------------------------------- /src/pkgs/misc/vim-plugins/lib.nix: -------------------------------------------------------------------------------- 1 | { lib }: { 2 | inherit (lib) filterSources; 3 | } 4 | -------------------------------------------------------------------------------- /src/pkgs/misc/vim-plugins/utils.nix: -------------------------------------------------------------------------------- 1 | { lib, pkgSet, pkgSetUtils, vim }: 2 | let 3 | meta = { }; 4 | in pkgSetUtils // { 5 | pkgBuilder = prefix: pname: { meta ? pkgSetUtils.meta or meta, ... }@source: let 6 | source' = builtins.removeAttrs source [ "pname" ]; 7 | plugin = pkgSetUtils.buildVimPluginFrom2Nix (source' // { inherit pname; }); 8 | in lib.nameValuePair pname plugin; 9 | } 10 | -------------------------------------------------------------------------------- /src/pkgs/misc/vscode-extensions/lib.nix: -------------------------------------------------------------------------------- 1 | { lib }: rec { 2 | inherit (lib) filterSources; 3 | 4 | filterSources' = prefix: sources: 5 | let 6 | sources' = filterSources prefix sources; 7 | publishers = lib.groupBy 8 | (source: source.publisher) 9 | (builtins.attrValues sources'); 10 | in publishers; 11 | } 12 | -------------------------------------------------------------------------------- /src/pkgs/misc/vscode-extensions/utils.nix: -------------------------------------------------------------------------------- 1 | { lib, pkgSet, pkgSetUtils, vscode, libarchive }: 2 | let 3 | meta' = { inherit (vscode) platforms; }; 4 | in pkgSetUtils // rec { 5 | pkgBuilder = 6 | prefix: name': 7 | { src 8 | , pname 9 | , version 10 | 11 | , name 12 | , publisher 13 | 14 | , meta ? pkgSetUtils.meta or meta' 15 | , ... 16 | }@source: 17 | let 18 | source' = builtins.removeAttrs source 19 | [ 20 | "src" 21 | "pname" 22 | "name" 23 | "publisher" 24 | "version" 25 | ]; 26 | ext = pkgSetUtils.buildVscodeMarketplaceExtension (source' // { 27 | vsix = src; 28 | mktplcRef = { inherit version name publisher; }; 29 | buildInputs = [ libarchive ]; 30 | unpackPhase = '' 31 | bsdtar xvf "$src" --strip-components=1 'extension/*' 32 | ''; 33 | }); 34 | in lib.nameValuePair (lib.toLower name') ext; 35 | 36 | pkgBuilder' = prefix: publisher: sources: 37 | let 38 | pkgSet' = pkgSet."${publisher}" or { }; 39 | exts = lib.foldl' (r: e: 40 | let 41 | inherit (pkgBuilder prefix e.name e) name value; 42 | in r // { "${name}" = value; } 43 | ) { } sources; 44 | in lib.nameValuePair (lib.toLower publisher) (pkgSet' // exts); 45 | } -------------------------------------------------------------------------------- /ufr-polyfills/UnofficialFlakesRoadmap.md: -------------------------------------------------------------------------------- 1 | # Hey! 2 | 3 | This project is commited to the [Unofficial Flakes Roadmap (ufr)](https://demo.hedgedoc.org/s/_W6Ve03GK#). 4 | 5 | 6 | _The future of flakes is bright again._ 7 | -------------------------------------------------------------------------------- /ufr-polyfills/eachSystem.nix: -------------------------------------------------------------------------------- 1 | # Builds a map from value to =value for each system. 2 | # .. adopted from: https://github.com/numtide/flake-utils 3 | # 4 | systems: f: 5 | let 6 | op = attrs: system: 7 | attrs // { 8 | "${system}" = f system; 9 | }; 10 | in 11 | builtins.foldl' op { } systems 12 | -------------------------------------------------------------------------------- /ufr-polyfills/flake.lock.nix: -------------------------------------------------------------------------------- 1 | # Adapted from https://github.com/edolstra/flake-compat/blob/master/default.nix 2 | # 3 | # This version only gives back the inputs. In that mode, flake becomes little 4 | # more than a niv replacement. 5 | src: 6 | let 7 | lockFilePath = src + "/flake.lock"; 8 | 9 | lockFile = builtins.fromJSON (builtins.readFile lockFilePath); 10 | 11 | # Emulate builtins.fetchTree 12 | # 13 | # TODO: only implement polyfill if the builtin doesn't exist? 14 | fetchTree = 15 | info: 16 | if info.type == "github" then 17 | { 18 | outPath = fetchTarball { 19 | url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; 20 | sha256 = info.narHash; 21 | }; 22 | inherit (info) rev; 23 | shortRev = builtins.substring 0 7 info.rev; 24 | inherit (info) lastModified; 25 | inherit (info) narHash; 26 | } 27 | else if info.type == "git" then 28 | { 29 | outPath = 30 | builtins.fetchGit 31 | ({ inherit (info) url; sha256 = info.narHash; } 32 | // (if info ? rev then { inherit (info) rev; } else { }) 33 | // (if info ? ref then { inherit (info) ref; } else { }) 34 | ); 35 | inherit (info) lastModified; 36 | inherit (info) narHash; 37 | } // (if info ? rev then { 38 | inherit (info) rev; 39 | shortRev = builtins.substring 0 7 info.rev; 40 | } else { }) 41 | else if info.type == "path" then 42 | { 43 | outPath = builtins.path { inherit (info) path; }; 44 | inherit (info) narHash; 45 | } 46 | else if info.type == "tarball" then 47 | { 48 | outPath = fetchTarball { 49 | inherit (info) url; 50 | sha256 = info.narHash; 51 | }; 52 | inherit (info) narHash; 53 | } 54 | else if info.type == "gitlab" then 55 | { 56 | inherit (info) rev narHash lastModified; 57 | outPath = fetchTarball { 58 | url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; 59 | sha256 = info.narHash; 60 | }; 61 | shortRev = builtins.substring 0 7 info.rev; 62 | } 63 | else 64 | # FIXME: add Mercurial, tarball inputs. 65 | throw "flake input has unsupported input type '${info.type}'"; 66 | 67 | allNodes = 68 | builtins.mapAttrs 69 | (key: node: 70 | let 71 | sourceInfo = 72 | if key == lockFile.root 73 | then { } 74 | else fetchTree (node.info or { } // removeAttrs node.locked [ "dir" ]); 75 | 76 | inputs = builtins.mapAttrs 77 | (inputName: inputSpec: allNodes."${resolveInput inputSpec}") 78 | (node.inputs or { }); 79 | 80 | # Resolve a input spec into a node name. An input spec is 81 | # either a node name, or a 'follows' path from the root 82 | # node. 83 | resolveInput = inputSpec: 84 | if builtins.isList inputSpec 85 | then getInputByPath lockFile.root inputSpec 86 | else inputSpec; 87 | 88 | # Follow an input path (e.g. ["dwarffs" "nixpkgs"]) from the 89 | # root node, returning the final node. 90 | getInputByPath = nodeName: path: 91 | if path == [ ] 92 | then nodeName 93 | else 94 | getInputByPath 95 | # Since this could be a 'follows' input, call resolveInput. 96 | (resolveInput lockFile.nodes."${nodeName}".inputs."${builtins.head path}") 97 | (builtins.tail path); 98 | 99 | result = sourceInfo // { inherit inputs; inherit sourceInfo; }; 100 | in 101 | if node.flake or true then 102 | result 103 | else 104 | sourceInfo 105 | ) 106 | lockFile.nodes; 107 | 108 | result = 109 | if lockFile.version >= 5 && lockFile.version <= 7 110 | then allNodes."${lockFile.root}".inputs 111 | else throw "lock file '${lockFilePath}' has unsupported version ${toString lockFile.version}"; 112 | 113 | in 114 | result 115 | -------------------------------------------------------------------------------- /ufr-polyfills/ufrContract.nix: -------------------------------------------------------------------------------- 1 | let 2 | eachSystem = import ./eachSystem.nix; 3 | in 4 | 5 | supportedSystems: 6 | imprt: inputs: self: 7 | eachSystem supportedSystems (system: 8 | import imprt { 9 | inherit inputs system self; # The super stupid flakes contract `{ inputs, system }` 10 | } 11 | ) 12 | --------------------------------------------------------------------------------