+4
-11
README.md
+4
-11
README.md
···
9
9
10
10
This repo contains several non-flakes examples (one per branch):
11
11
12
-
- [unflake](https://github.com/vic/dendritic-unflake/tree/main) **current**
12
+
- [unflake](https://github.com/vic/dendritic-unflake/tree/main)
13
13
- [npins](https://github.com/vic/dendritic-unflake/tree/npins)
14
-
- [builtins](https://github.com/vic/dendritic-unflake/tree/builtins)
14
+
- [builtins](https://github.com/vic/dendritic-unflake/tree/builtins) **current**
15
15
- [froyo](https://github.com/vic/dendritic-unflake/tree/froyo)
16
16
- [falake](https://github.com/vic/dendritic-unflake/tree/falake)
17
17
- [flake-parts](https://github.com/vic/dendritic-unflake/tree/flake-parts)
18
18
19
19
20
-
# Dendritic unflake
20
+
# Dendritic stable-nix
21
21
22
22
This repository serves as an example Dendritic Nix implementation **without** flakes nor flake-parts.
23
23
([discourse post](https://discourse.nixos.org/t/dendritic-unflake-example-dendritic-setup-without-flakes-nor-flake-parts/73069/5) and [context](https://github.com/mightyiam/dendritic/pull/15))
24
24
25
-
26
25
Entry point is [default.nix](default.nix), [modules/example.nix](modules/example.nix) defines a nixosConfiguration.
27
26
28
27
29
-
This example uses [unflake](https://discourse.nixos.org/t/unflake-flake-dependencies-for-non-flake-projects-and-a-way-to-stop-writing-follows/72611) to fetch dependencies and provide flake-like inputs.
28
+
This example uses `builtins.fetchGit` to fetch dependencies and [with-inputs.nix](with-inputs.nix) to provide flake-like inputs.
30
29
31
30
32
31
## Usage
33
-
34
-
Regenerate [unflake.nix](unflake.nix) whenever [inputs.nix](inputs.nix) change:
35
-
36
-
```console
37
-
nix-shell https://ln-s.sh/unflake -A unflake-shell --run unflake
38
-
```
39
32
40
33
Build `my-laptop` nixos config:
41
34
+1
-1
default.nix
+1
-1
default.nix
-5
inputs.nix
-5
inputs.nix
-41
unflake.nix
-41
unflake.nix
···
1
-
let
2
-
deps = rec {
3
-
unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable = builtins.fetchTree {
4
-
type = "github";
5
-
owner = "nixos";
6
-
repo = "nixpkgs";
7
-
rev = "677fbe97984e7af3175b6c121f3c39ee5c8d62c9";
8
-
narHash = "sha256-g2a4MhRKu4ymR4xwo+I+auTknXt/+j37Lnf0Mvfl1rE=";
9
-
};
10
-
unflake_github_vic_import-tree = builtins.fetchTree {
11
-
type = "github";
12
-
owner = "vic";
13
-
repo = "import-tree";
14
-
rev = "3c23749d8013ec6daa1d7255057590e9ca726646";
15
-
narHash = "sha256-ZvYKbFib3AEwiNMLsejb/CWs/OL/srFQ8AogkebEPF0=";
16
-
};
17
-
};
18
-
universe = rec {
19
-
unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable = ((import "${deps.unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable.outPath}/flake.nix").outputs {
20
-
self = unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable;
21
-
}) // deps.unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable // {
22
-
_flake = true;
23
-
outPath = "${deps.unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable.outPath}";
24
-
sourceInfo = deps.unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable;
25
-
};
26
-
unflake_github_vic_import-tree = ((import "${deps.unflake_github_vic_import-tree.outPath}/flake.nix").outputs {
27
-
self = unflake_github_vic_import-tree;
28
-
}) // deps.unflake_github_vic_import-tree // {
29
-
_flake = true;
30
-
outPath = "${deps.unflake_github_vic_import-tree.outPath}";
31
-
sourceInfo = deps.unflake_github_vic_import-tree;
32
-
};
33
-
};
34
-
inputs = {
35
-
import-tree = universe.unflake_github_vic_import-tree;
36
-
nixpkgs = universe.unflake_github_nixos_nixpkgs_ref_nixpkgs-unstable;
37
-
self = throw "to use inputs.self, write `import ./unflake.nix (inputs: ...)`";
38
-
withInputs = outputs: let self = outputs (inputs // { inherit self; }); in self;
39
-
__functor = self: self.withInputs;
40
-
};
41
-
in inputs
+51
with-inputs.nix
+51
with-inputs.nix
···
1
+
let
2
+
sources = {
3
+
# impure: from local nixpkgs registry, replace with fixed fetchGit if desired.
4
+
nixpkgs.outPath = <nixpkgs>;
5
+
6
+
import-tree = builtins.fetchGit {
7
+
url = "https://github.com/vic/import-tree.git";
8
+
ref = "main";
9
+
shallow = true;
10
+
narHash = "sha256-ZvYKbFib3AEwiNMLsejb/CWs/OL/srFQ8AogkebEPF0=";
11
+
rev = "3c23749d8013ec6daa1d7255057590e9ca726646";
12
+
};
13
+
};
14
+
15
+
selfInputs = builtins.mapAttrs (name: value: mkInputs name value) sources;
16
+
# from Nixlock: https://codeberg.org/FrdrCkII/nixlock/src/branch/main/default.nix
17
+
mkInputs =
18
+
name: sourceInfo:
19
+
let
20
+
flakePath = sourceInfo.outPath + "/flake.nix";
21
+
isFlake = sources.${name}.flake or true;
22
+
in
23
+
if isFlake && builtins.pathExists flakePath then
24
+
let
25
+
flake = import (sourceInfo.outPath + "/flake.nix");
26
+
inputs = builtins.mapAttrs (name: value: selfInputs.${name}) (flake.inputs or { });
27
+
outputs = flake.outputs (inputs // { inherit self; });
28
+
self =
29
+
sourceInfo
30
+
// outputs
31
+
// {
32
+
_type = "flake";
33
+
inherit inputs sourceInfo;
34
+
};
35
+
in
36
+
self
37
+
else
38
+
sourceInfo
39
+
// {
40
+
inherit sourceInfo;
41
+
};
42
+
in
43
+
selfInputs
44
+
// {
45
+
__functor =
46
+
selfInputs: outputs:
47
+
let
48
+
self = outputs (selfInputs // { inherit self; });
49
+
in
50
+
self;
51
+
}