···11111212- [unflake](https://github.com/vic/dendritic-unflake/tree/main)
1313- [npins](https://github.com/vic/dendritic-unflake/tree/npins)
1414-- [builtins](https://github.com/vic/dendritic-unflake/tree/builtins)
1414+- [builtins](https://github.com/vic/dendritic-unflake/tree/builtins) **current**
1515- [froyo](https://github.com/vic/dendritic-unflake/tree/froyo)
1616-- [falake](https://github.com/vic/dendritic-unflake/tree/falake) **current**
1616+- [falake](https://github.com/vic/dendritic-unflake/tree/falake)
1717- [flake-parts](https://github.com/vic/dendritic-unflake/tree/flake-parts)
18181919-# Dendritic Falake
1919+2020+# Dendritic stable-nix
20212122This repository serves as an example Dendritic Nix implementation **without** flakes nor flake-parts.
2223([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))
···2425Entry point is [default.nix](default.nix), [modules/example.nix](modules/example.nix) defines a nixosConfiguration.
252626272727-This example uses [falake](https://codeberg.org/FrdrCkII/falake) top-level modules.
2828+This example uses `builtins.fetchGit` to fetch dependencies and [with-inputs.nix](with-inputs.nix) to provide flake-like inputs.
282929303031## Usage
···11-/*
22- This file is provided under the MIT licence:
33-44- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the โSoftwareโ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55-66- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
77-88- THE SOFTWARE IS PROVIDED โAS ISโ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99-*/
1010-# Generated by npins. Do not modify; will be overwritten regularly
1111-let
1212- data = builtins.fromJSON (builtins.readFile ./sources.json);
1313- version = data.version;
1414-1515- # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
1616- range =
1717- first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
1818-1919- # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
2020- stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
2121-2222- # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
2323- stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
2424- concatMapStrings = f: list: concatStrings (map f list);
2525- concatStrings = builtins.concatStringsSep "";
2626-2727- # If the environment variable NPINS_OVERRIDE_${name} is set, then use
2828- # the path directly as opposed to the fetched source.
2929- # (Taken from Niv for compatibility)
3030- mayOverride =
3131- name: path:
3232- let
3333- envVarName = "NPINS_OVERRIDE_${saneName}";
3434- saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
3535- ersatz = builtins.getEnv envVarName;
3636- in
3737- if ersatz == "" then
3838- path
3939- else
4040- # this turns the string into an actual Nix path (for both absolute and
4141- # relative paths)
4242- builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
4343- if builtins.substring 0 1 ersatz == "/" then
4444- /. + ersatz
4545- else
4646- /. + builtins.getEnv "PWD" + "/${ersatz}"
4747- );
4848-4949- mkSource =
5050- name: spec:
5151- assert spec ? type;
5252- let
5353- path =
5454- if spec.type == "Git" then
5555- mkGitSource spec
5656- else if spec.type == "GitRelease" then
5757- mkGitSource spec
5858- else if spec.type == "PyPi" then
5959- mkPyPiSource spec
6060- else if spec.type == "Channel" then
6161- mkChannelSource spec
6262- else if spec.type == "Tarball" then
6363- mkTarballSource spec
6464- else
6565- builtins.throw "Unknown source type ${spec.type}";
6666- in
6767- spec // { outPath = mayOverride name path; };
6868-6969- mkGitSource =
7070- {
7171- repository,
7272- revision,
7373- url ? null,
7474- submodules,
7575- hash,
7676- branch ? null,
7777- ...
7878- }:
7979- assert repository ? type;
8080- # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
8181- # In the latter case, there we will always be an url to the tarball
8282- if url != null && !submodules then
8383- builtins.fetchTarball {
8484- inherit url;
8585- sha256 = hash; # FIXME: check nix version & use SRI hashes
8686- }
8787- else
8888- let
8989- url =
9090- if repository.type == "Git" then
9191- repository.url
9292- else if repository.type == "GitHub" then
9393- "https://github.com/${repository.owner}/${repository.repo}.git"
9494- else if repository.type == "GitLab" then
9595- "${repository.server}/${repository.repo_path}.git"
9696- else
9797- throw "Unrecognized repository type ${repository.type}";
9898- urlToName =
9999- url: rev:
100100- let
101101- matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
102102-103103- short = builtins.substring 0 7 rev;
104104-105105- appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
106106- in
107107- "${if matched == null then "source" else builtins.head matched}${appendShort}";
108108- name = urlToName url revision;
109109- in
110110- builtins.fetchGit {
111111- rev = revision;
112112- inherit name;
113113- # hash = hash;
114114- inherit url submodules;
115115- };
116116-117117- mkPyPiSource =
118118- { url, hash, ... }:
119119- builtins.fetchurl {
120120- inherit url;
121121- sha256 = hash;
122122- };
123123-124124- mkChannelSource =
125125- { url, hash, ... }:
126126- builtins.fetchTarball {
127127- inherit url;
128128- sha256 = hash;
129129- };
130130-131131- mkTarballSource =
132132- {
133133- url,
134134- locked_url ? url,
135135- hash,
136136- ...
137137- }:
138138- builtins.fetchTarball {
139139- url = locked_url;
140140- sha256 = hash;
141141- };
142142-in
143143-if version == 5 then
144144- builtins.mapAttrs mkSource data.pins
145145-else
146146- throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"