1
1
mirror of https://github.com/divnix/digga.git synced 2024-08-15 10:00:22 +03:00

Cleanup how polyfill works for digga-use outputs

This commit is contained in:
Parthiv Seetharaman 2022-01-30 13:30:31 -08:00
parent 8a77ad799f
commit d17be3c12b
12 changed files with 59 additions and 399 deletions

View File

@ -1,12 +1,11 @@
{ system ? builtins.currentSystem
, inputs # flake style polyfill not possible, since this depends on digga's internals
, inputs ? (import ../.).inputs
}:
let
nixpkgs = inputs.nixpkgs;
digga = inputs.digga;
inherit (inputs) digga nixpkgs;
lib = nixpkgs.lib // digga.lib;
pkgs = import nixpkgs { inherit system; config = { }; overlays = [ ]; };
pkgs = nixpkgs.legacyPackages.${system};
in
{

15
default.nix Normal file
View File

@ -0,0 +1,15 @@
let
inherit (import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
) defaultNix;
in
# Pass this flake as inputs.digga
defaultNix // { inputs = defaultNix.inputs // { digga = defaultNix; }; }

View File

@ -68,6 +68,22 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1641205782,
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1638122382,
@ -210,6 +226,7 @@
"blank": "blank",
"deploy": "deploy",
"devshell": "devshell",
"flake-compat": "flake-compat_2",
"flake-utils-plus": "flake-utils-plus",
"home-manager": "home-manager",
"latest": "latest",

View File

@ -23,6 +23,11 @@
nixos-generators.url = "github:nix-community/nixos-generators";
nixos-generators.inputs.nixpkgs.follows = "blank";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs =
@ -69,22 +74,23 @@
};
# Unofficial Flakes Roadmap - Polyfills
# This project is committed to the Unofficial Flakes Roadmap!
# .. see: https://demo.hedgedoc.org/s/_W6Ve03GK#
# .. also: <repo-root>/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
checksInputs = { inherit nixpkgs; digga = self; };
jobsInputs = { inherit nixpkgs; digga = self; };
devShellInputs = { inherit nixpkgs devshell; };
# Pass this flake(self) as "digga"
polyfillInputs = self.inputs // { digga = self; };
polyfillOutput = loc: nixlib.lib.genAttrs supportedSystems (system:
import loc { inherit system; inputs = polyfillInputs; }
);
# .. 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.
# DEPRECATED - will be removed timely
deprecated = import ./deprecated.nix {
inherit (nixlib) lib;
@ -128,10 +134,10 @@
'';
# digga-local use
jobs = ufrContract supportedSystems ./jobs jobsInputs;
checks = ufrContract supportedSystems ./checks checksInputs;
devShell = ufrContract supportedSystems ./shell.nix devShellInputs;
# system-space and pass sytem and input to each file
jobs = polyfillOutput ./jobs;
checks = polyfillOutput ./checks;
devShell = polyfillOutput ./shell.nix;
};
}

View File

@ -1,11 +1,10 @@
{ system ? builtins.currentSystem
, inputs ? import ../ufr-polyfills/flake.lock.nix ./.
, inputs ? (import ../.).inputs
}:
let
nixpkgs = inputs.nixpkgs;
digga = inputs.digga;
pkgs = import nixpkgs { inherit system; config = { }; overlays = [ ]; };
inherit (inputs) digga;
pkgs = inputs.nixpkgs.legacyPackages.${system};
docOptions = digga.lib.mkFlake.options { self = { }; inputs = { }; };
evaledOptions = (pkgs.lib.evalModules { modules = [ docOptions ]; }).options;

View File

@ -1,197 +0,0 @@
{
"nodes": {
"deploy": {
"inputs": {
"flake-compat": "flake-compat",
"naersk": "naersk",
"nixpkgs": [
"digga",
"nixpkgs"
],
"utils": [
"digga",
"utils"
]
},
"locked": {
"lastModified": 1623011836,
"narHash": "sha256-02M4P3eqUdV+ouZb8n1KDR1CXeZQm17cKpjKZKi0c10=",
"owner": "serokell",
"repo": "deploy-rs",
"rev": "70d71b3027b1793b780f1e2435bdbbe1b0cb9ac6",
"type": "github"
},
"original": {
"owner": "serokell",
"repo": "deploy-rs",
"type": "github"
}
},
"devshell": {
"locked": {
"lastModified": 1622013274,
"narHash": "sha256-mK/Lv0lCbl07dI5s7tR/7nb79HunKnJik3KyR6yeI2k=",
"owner": "numtide",
"repo": "devshell",
"rev": "e7faf69e6bf8546517cc936c7f6d31c7eb3abcb2",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"digga": {
"inputs": {
"deploy": "deploy",
"devshell": "devshell",
"nixlib": "nixlib",
"nixos-generators": "nixos-generators",
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"narHash": "sha256-BimhA1sw5W+BnMdLfVrMS+WVDv3vi73OlRCyQI+xQkU=",
"path": "../",
"type": "path"
},
"original": {
"path": "../",
"type": "path"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1606424373,
"narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1623660459,
"narHash": "sha256-OTmOsh43po7r5F9s9H6lVCBQ2b0FikWbmiwLbMAGRdw=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "98c8d36b1828009b20f12544214683c7489935a1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"digga",
"nixpkgs"
]
},
"locked": {
"lastModified": 1622810282,
"narHash": "sha256-4wmvM3/xfD0hCdNDIXVzRMfL4yB1J+DjH6Zte2xbAxk=",
"owner": "nmattia",
"repo": "naersk",
"rev": "e8061169e1495871b56be97c5c51d310fae01374",
"type": "github"
},
"original": {
"owner": "nmattia",
"ref": "master",
"repo": "naersk",
"type": "github"
}
},
"nixlib": {
"locked": {
"lastModified": 1620519687,
"narHash": "sha256-+6Dd72b2CASuXm2W7KRxZIE7AOy/dj4mU28vaF+zxcs=",
"owner": "divnix",
"repo": "nixpkgs.lib",
"rev": "c7b6169809c5f74dd0c34f3d69e9d12ba4d448de",
"type": "github"
},
"original": {
"owner": "divnix",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixos-generators": {
"inputs": {
"nixpkgs": [
"digga",
"nixpkgs"
]
},
"locked": {
"lastModified": 1624117213,
"narHash": "sha256-hAoBANafVdM/+8Z6PrlPEKPN6LrdkM4qg2Q/ji0XUns=",
"owner": "nix-community",
"repo": "nixos-generators",
"rev": "c64d3c2153274a6ab355e57f5eedfe6f85073d24",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-generators",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1624300589,
"narHash": "sha256-anxKmaq18nWRzrgbPOajbjuq1cqsqgSsj1LTwU+7oQ4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "38d369643e49043923a6d0e66e60b7fe54291d69",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"digga": "digga",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"inputs": {
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1624128793,
"narHash": "sha256-yZYvpT6i6iRK0x1a8k/LCoS7JGLVk6Yi1eqfhatnDLk=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "785e6f13b8c6131d1eee625a713e8475b2b0512b",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"ref": "staging",
"repo": "flake-utils-plus",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -1,33 +0,0 @@
{
description = "Digga Library Jobs";
inputs = {
digga.url = "path:../";
digga.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs @ { self, nixpkgs, digga }:
let
# Unofficial Flakes Roadmap - Polyfills
# .. see: https://demo.hedgedoc.org/s/_W6Ve03GK#
# .. also: <repo-root>/ufr-polyfills
# Super Stupid Flakes / System As an Input - Style:
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
ufrContract = import ../ufr-polyfills/ufrContract.nix;
# Dependency Groups - Style
jobsInputs = { inherit nixpkgs digga; };
# .. 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.
in
{
jobs = ufrContract supportedSystems ./. jobsInputs;
};
}

View File

@ -1,10 +1,9 @@
{ inputs, system ? builtins.currentSystem }:
{ system ? builtins.currentSystem
, inputs ? (import ./.).inputs
}:
let
pkgs = import inputs.nixpkgs {
inherit system; config = { };
overlays = [ ];
};
pkgs = inputs.nixpkgs.legacyPackages.${system};
devshell = import inputs.devshell { inherit pkgs system; };
withCategory = category: attrset: attrset // { inherit category; };

View File

@ -1,7 +0,0 @@
# Hey!
This project is committed to the [Unofficial Flakes Roadmap (ufr)](https://demo.hedgedoc.org/s/_W6Ve03GK#).
_The future of flakes is bright again._

View File

@ -1,12 +0,0 @@
# Builds a map from value to <system>=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

View File

@ -1,115 +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;
};
rev = info.rev;
shortRev = builtins.substring 0 7 info.rev;
lastModified = info.lastModified;
narHash = info.narHash;
}
else if info.type == "git" then
{
outPath =
builtins.fetchGit
({ url = info.url; sha256 = info.narHash; }
// (if info ? rev then { inherit (info) rev; } else { })
// (if info ? ref then { inherit (info) ref; } else { })
);
lastModified = info.lastModified;
narHash = info.narHash;
} // (if info ? rev then {
rev = info.rev;
shortRev = builtins.substring 0 7 info.rev;
} else { })
else if info.type == "path" then
{
outPath = builtins.path { path = info.path; };
narHash = info.narHash;
}
else if info.type == "tarball" then
{
outPath = fetchTarball {
url = info.url;
sha256 = info.narHash;
};
narHash = 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

View File

@ -1,11 +0,0 @@
let
eachSystem = import ./eachSystem.nix;
in
supportedSystems:
imprt: inputs:
eachSystem supportedSystems (system:
import imprt {
inherit inputs system; # The super stupid flakes contract `{ inputs, system }`
}
)