mirror of
https://github.com/divnix/digga.git
synced 2024-12-23 08:02:21 +03:00
ref: we love the unofficial flakes roadmap
This commit is contained in:
parent
a680bc2529
commit
7608f9585c
@ -1,8 +1,10 @@
|
|||||||
{ inputs, system ? builtins.currentSystem }:
|
{ system ? builtins.currentSystem
|
||||||
|
, inputs # flake style polyfill not possible, since this depends on digga's internals
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
nixpkgs = inputs.nixpkgs;
|
nixpkgs = inputs.nixpkgs;
|
||||||
diggalib = inputs.lib;
|
diggalib = inputs.lib; # digga internals
|
||||||
nixlib = inputs.nixlib;
|
nixlib = inputs.nixlib;
|
||||||
lib = nixlib // diggalib;
|
lib = nixlib // diggalib;
|
||||||
pkgs = import nixpkgs { inherit system; config = { }; overlays = [ ]; };
|
pkgs = import nixpkgs { inherit system; config = { }; overlays = [ ]; };
|
||||||
|
43
flake.nix
43
flake.nix
@ -24,7 +24,6 @@
|
|||||||
utils.follows = "utils";
|
utils.follows = "utils";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
@ -38,6 +37,7 @@
|
|||||||
, ...
|
, ...
|
||||||
}@inputs:
|
}@inputs:
|
||||||
let
|
let
|
||||||
|
|
||||||
lib = nixlib.lib.makeExtensible (self:
|
lib = nixlib.lib.makeExtensible (self:
|
||||||
let combinedLib = nixlib.lib // self; in
|
let combinedLib = nixlib.lib // self; in
|
||||||
with self;
|
with self;
|
||||||
@ -81,6 +81,23 @@
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Unofficial Flakes Roadmap - Polyfills
|
||||||
|
# .. 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 lib; nixlib = nixlib.lib; };
|
||||||
|
jobsInputs = { inherit nixpkgs; digga = self; };
|
||||||
|
devShellInputs = { inherit nixpkgs devshell; };
|
||||||
|
|
||||||
|
# .. 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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -93,25 +110,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
# digga-local use
|
# digga-local use
|
||||||
|
jobs = ufrContract supportedSystems ./jobs jobsInputs;
|
||||||
checks.x86_64-linux = import ./checks {
|
checks = ufrContract supportedSystems ./checks checksInputs;
|
||||||
inputs = { inherit nixpkgs lib; nixlib = nixlib.lib; };
|
devShell = ufrContract supportedSystems ./shell.nix devShellInputs;
|
||||||
system = "x86_64-linux";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
jobs.x86_64-linux = import ./jobs {
|
|
||||||
inputs = { inherit nixpkgs; digga = self; };
|
|
||||||
system = "x86_64-linux";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
utils.lib.eachDefaultSystem (system: {
|
|
||||||
devShell = import ./shell.nix {
|
|
||||||
inputs = { inherit nixpkgs devshell; };
|
|
||||||
inherit system;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
{ inputs, system ? builtins.currentSystem }:
|
{ system ? builtins.currentSystem
|
||||||
|
, inputs ? import ../ufr-polyfills/flake.lock.nix ./.
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
nixpkgs = inputs.nixpkgs;
|
nixpkgs = inputs.nixpkgs;
|
||||||
|
197
jobs/flake.lock
Normal file
197
jobs/flake.lock
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
@ -1,15 +1,32 @@
|
|||||||
{
|
{
|
||||||
description = "Digga Library Jobs";
|
description = "Digga Library Jobs";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
digga.url = "path:../";
|
digga.url = "path:../";
|
||||||
digga.inputs.nixpkgs.follows = "nixpkgs";
|
digga.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
outputs = inputs @ { self, nixpkgs, digga }: {
|
|
||||||
|
|
||||||
jobs.x86_64-linux = import ./. {
|
outputs = inputs @ { self, nixpkgs, digga }: let
|
||||||
inherit inputs;
|
|
||||||
system = "x86_64-linux";
|
# 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 ./jobs jobsInputs;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
7
ufr-polyfills/UnofficialFlakesRoadmap.md
Normal file
7
ufr-polyfills/UnofficialFlakesRoadmap.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Hey!
|
||||||
|
|
||||||
|
This project is commited to the [Unofficial Flakes Roadmap (ufr)](https://demo.hedgedoc.org/s/_W6Ve03GK#).
|
||||||
|
|
||||||
|
|
||||||
|
_The future of flakes is bright again._
|
||||||
|
|
12
ufr-polyfills/eachSystem.nix
Normal file
12
ufr-polyfills/eachSystem.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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
|
||||||
|
|
106
ufr-polyfills/flake.lock.nix
Normal file
106
ufr-polyfills/flake.lock.nix
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# 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 "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}";
|
||||||
|
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; }
|
||||||
|
// (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 info.url;
|
||||||
|
narHash = info.narHash;
|
||||||
|
}
|
||||||
|
else if info.type == "gitlab" then
|
||||||
|
{
|
||||||
|
inherit (info) rev narHash lastModified;
|
||||||
|
outPath = fetchTarball "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}";
|
||||||
|
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
|
||||||
|
|
11
ufr-polyfills/ufrContract.nix
Normal file
11
ufr-polyfills/ufrContract.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
let
|
||||||
|
eachSystem = import ./eachSystem.nix;
|
||||||
|
in
|
||||||
|
|
||||||
|
supportedSystems:
|
||||||
|
imprt: inputs:
|
||||||
|
eachSystem supportedSystems (system:
|
||||||
|
import imprt {
|
||||||
|
inherit inputs system; # The super stupid flakes contract `{ inputs, system }`
|
||||||
|
}
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user