diff --git a/default.nix b/default.nix --- a/default.nix +++ b/default.nix @@ -1,4 +1,19 @@ { system ? builtins.currentSystem, + inputs ? import ./.tack, + pkgs ? import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }, + craneLib ? (import inputs.crane { inherit pkgs; }).overrideToolchain ( + p: p.rust-bin.stable.latest.default + ), }: -(import ./nix { inherit system; }).sandhole +(import ./nix { + inherit + system + inputs + pkgs + craneLib + ; +}).sandhole diff --git a/flake.lock b/flake.lock --- a/flake.lock +++ b/flake.lock @@ -1,63 +1,6 @@ { "nodes": { - "crane": { - "flake": false, - "locked": { - "lastModified": 1781033631, - "narHash": "sha256-fA+Sl81N7afKXvd0AzPB45e164CgEyX/96OnedaKhbY=", - "owner": "EpicEric", - "repo": "dummy.nix", - "rev": "7ee5540ff5cb7eb0b01d66a97d66772c9af99d1c", - "type": "github" - }, - "original": { - "owner": "EpicEric", - "ref": "main", - "repo": "dummy.nix", - "type": "github" - } - }, - "nixpkgs": { - "flake": false, - "locked": { - "lastModified": 1781033631, - "narHash": "sha256-fA+Sl81N7afKXvd0AzPB45e164CgEyX/96OnedaKhbY=", - "owner": "EpicEric", - "repo": "dummy.nix", - "rev": "7ee5540ff5cb7eb0b01d66a97d66772c9af99d1c", - "type": "github" - }, - "original": { - "owner": "EpicEric", - "ref": "main", - "repo": "dummy.nix", - "type": "github" - } - }, - "root": { - "inputs": { - "crane": "crane", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" - } - }, - "rust-overlay": { - "flake": false, - "locked": { - "lastModified": 1781033631, - "narHash": "sha256-fA+Sl81N7afKXvd0AzPB45e164CgEyX/96OnedaKhbY=", - "owner": "EpicEric", - "repo": "dummy.nix", - "rev": "7ee5540ff5cb7eb0b01d66a97d66772c9af99d1c", - "type": "github" - }, - "original": { - "owner": "EpicEric", - "ref": "main", - "repo": "dummy.nix", - "type": "github" - } - } + "root": {} }, "root": "root", "version": 7 diff --git a/flake.nix b/flake.nix --- a/flake.nix +++ b/flake.nix @@ -1,24 +1,13 @@ { description = "Expose HTTP/SSH/TCP services through SSH port forwarding"; - inputs = { - crane = { - url = "github:EpicEric/dummy.nix/main"; - flake = false; - }; - nixpkgs = { - url = "github:EpicEric/dummy.nix/main"; - flake = false; - }; - rust-overlay = { - url = "github:EpicEric/dummy.nix/main"; - flake = false; - }; - }; - outputs = - { self, ... }@inputs: + { self, ... }@args: let + inputs = (import ./.tack) { + overrides = args.tackOverrides or { }; + }; + systems = [ "x86_64-linux" "aarch64-linux" @@ -68,15 +57,11 @@ // eachSystem ( system: let - sources = import ./npins; - importInput = - attr: - if import inputs.${attr} ? __isDummyInput then import sources.${attr} else import inputs.${attr}; - pkgs = importInput "nixpkgs" { + pkgs = import inputs.nixpkgs { inherit system; - overlays = [ (importInput "rust-overlay") ]; + overlays = [ (import inputs.rust-overlay) ]; }; - craneLib = (importInput "crane" { inherit pkgs; }).overrideToolchain ( + craneLib = (import inputs.crane { inherit pkgs; }).overrideToolchain ( p: p.rust-bin.stable.latest.default ); diff --git a/shell.nix b/shell.nix --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,19 @@ { system ? builtins.currentSystem, + inputs ? import ./.tack, + pkgs ? import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }, + craneLib ? (import inputs.crane { inherit pkgs; }).overrideToolchain ( + p: p.rust-bin.stable.latest.default + ), }: -(import ./nix { inherit system; }).shell +(import ./nix { + inherit + system + inputs + pkgs + craneLib + ; +}).shell diff --git a/.tack/default.nix b/.tack/default.nix new file mode 100644 --- /dev/null +++ b/.tack/default.nix @@ -0,0 +1,293 @@ +# SPDX-License-Identifier: EUPL-1.2 +# tack-managed resolver. delete this line to take ownership; tack will leave it alone afterwards. + +let + inherit (builtins) + attrNames + attrValues + concatMap + elemAt + filter + foldl' + fromJSON + head + intersectAttrs + isList + isString + listToAttrs + mapAttrs + match + pathExists + readFile + tail + trace + ; + + call = + { + overrides ? { }, + }: + let + pins = fromTOML (readFile ./pins.toml); + lock = fromJSON (readFile ./pins.lock.json); + all_follow_raw = pins.all_follow or { }; + + # flatten `target = [aliases]` rows alongside `alias = "target"` rows + all_follow = foldl' ( + acc: key: + let + val = all_follow_raw.${key}; + in + if isList val then + acc + // { + ${key} = key; + } + // listToAttrs ( + map (a: { + name = a; + value = key; + }) val + ) + else if isString val then + acc // { ${key} = val; } + else + acc + ) { } (attrNames all_follow_raw); + + fetchPin = name: fetchTree lock.${name}; + + fetchFixed = + name: entry: + let + raw = derivation { + inherit name; + inherit (entry) url; + builder = "builtin:fetchurl"; + system = "builtin"; + outputHash = entry.sha256; + outputHashAlgo = "sha256"; + outputHashMode = "flat"; + }; + unpacked = derivation { + inherit name; + builder = "builtin:unpack-channel"; + system = "builtin"; + src = raw; + channelName = name; + }; + in + if (entry.unpack or "file") == "tarball" then unpacked.outPath + "/" + name else raw.outPath; + + resolveSpec = upLock: spec: if isList spec then walkPath upLock upLock.root spec else spec; + + walkPath = + upLock: nodeName: path: + if path == [ ] then + nodeName + else + walkPath upLock (resolveSpec upLock upLock.nodes.${nodeName}.inputs.${head path}) (tail path); + + followsFor = + pin: + let + rules = removeAttrs all_follow (pin.exclude_follow or [ ]); + in + { + level = (pin.follows or { }) // rules; + deep = rules; + }; + + resolveFollows = mapAttrs ( + _: target: self.${target} or (throw "tack: follows target '${target}' is not a pin") + ); + + # a follows key is `flake:name`, `tack:name`, or a bare `name`. + # project a follows set onto one side, rekeyed to bare names. + followsForSide = + side: follows: + listToAttrs ( + concatMap ( + key: + let + m = match "(flake|tack):(.*)" key; + in + if m == null then + [ + { + name = key; + value = follows.${key}; + } + ] + else if head m == side then + [ + { + name = elemAt m 1; + value = follows.${key}; + } + ] + else + [ ] + ) (attrNames follows) + ); + + mkCallerInputs = + upLock: nodeName: rawInputs: levelFollows: deepFollows: + let + resolved = resolveFollows levelFollows; + in + mapAttrs ( + n: _decl: + resolved.${n} or ( + if upLock != null then + let + ref = + (upLock.nodes.${nodeName}.inputs or { }).${n} + or (throw "tack: input '${n}' declared but not in flake.lock node '${nodeName}'"); + childName = resolveSpec upLock ref; + childNode = upLock.nodes.${childName}; + childSrc = fetchTree childNode.locked; + in + if childNode.flake or true then evalTransitive upLock childName childSrc deepFollows else childSrc + else + throw "tack: no flake.lock; cannot resolve input '${n}'" + ) + ) rawInputs; + + mkFlakeResult = + sourceInfo: flakeDir: callerInputs: outputs: + outputs + // sourceInfo + // { + outPath = flakeDir; + inputs = callerInputs; + inherit outputs sourceInfo; + _type = "flake"; + }; + + evalFlake = + sourceInfo: flakeDir: upLock: nodeName: levelFollows: deepFollows: + let + raw = import (flakeDir + "/flake.nix"); + + tackPinsPath = flakeDir + "/.tack/pins.toml"; + hasTack = pathExists tackPinsPath; + upPins = if hasTack then fromTOML (readFile tackPinsPath) else { }; + + # project follows onto each side, then keep only the names that side has. + # note that a bare follow reaches both, a `flake:`/`tack:` follow just the one. + tackOverrides = resolveFollows ( + intersectAttrs (upPins.inputs or { }) (followsForSide "tack" levelFollows) + ); + flakeLevel = intersectAttrs (raw.inputs or { }) (followsForSide "flake" levelFollows); + + # deep follows pass down raw, so each descendant re-projects per side + callerInputs = mkCallerInputs upLock nodeName (raw.inputs or { }) flakeLevel deepFollows; + + # upstream's own claim that its outputs forward tackOverrides. a closed + # `{ self }:` upstream would throw on the extra kwarg, so forward only here. + supportsOverrides = (upPins.tack or { }).recomposable or false; + + extraArgs = if supportsOverrides && tackOverrides != { } then { inherit tackOverrides; } else { }; + + outputs = raw.outputs (callerInputs // extraArgs // { self = result; }); + + result = + let + base = mkFlakeResult sourceInfo flakeDir callerInputs outputs; + in + if hasTack && tackOverrides != { } && !supportsOverrides then + trace "tack: ${flakeDir}: not marked recomposable (set [tack] recomposable = true); overrides will not reach upstream" base + else + base; + in + result; + + evalTransitive = + upLock: nodeName: sourceInfo: follows: + evalFlake sourceInfo sourceInfo.outPath upLock nodeName follows follows; + + evalTopFlake = + sourceInfo: pin: + let + flakeDir = sourceInfo.outPath + (if pin ? dir then "/" + pin.dir else ""); + upLockPath = flakeDir + "/flake.lock"; + upLock = if pathExists upLockPath then fromJSON (readFile upLockPath) else null; + rootNode = if upLock != null then upLock.root else null; + f = followsFor pin; + in + evalFlake sourceInfo flakeDir upLock rootNode f.level f.deep; + + evalFetch = + sourceInfo: pin: subdir: + let + path = sourceInfo.outPath + subdir; + tackPinsPath = path + "/.tack/pins.toml"; + hasTack = pathExists tackPinsPath; + upPins = if hasTack then fromTOML (readFile tackPinsPath) else { }; + f = followsFor pin; + # a fetch drill-in is tack-only + tackOverrides = resolveFollows ( + intersectAttrs (upPins.inputs or { }) (followsForSide "tack" f.level) + ); + in + # a fetch pin is a source tree (a path). only when there are overrides to + # push into the upstream's own .tack do we hand back its resolved inputs + if hasTack && tackOverrides != { } then + let + upstream = import (path + "/.tack"); + in + # old resolvers return a plain attrset, not a callable functor + if upstream ? __functor then + (upstream { overrides = tackOverrides; }) // { outPath = path; } + else + trace "tack: ${path}: upstream .tack predates override support; overrides will not reach it" path + else + path; + + loadPin = + name: pin: + let + pinType = pin.type or (if pin.flake or true then "flake" else "fetch"); + subdir = if pin ? dir then "/" + pin.dir else ""; + in + if pinType == "fixed" then + fetchFixed name lock.${name} + else + let + sourceInfo = fetchPin name; + in + if pinType == "flake" then evalTopFlake sourceInfo pin else evalFetch sourceInfo pin subdir; + + declared = pins.inputs or { }; + + # undeclared lock entries are auto-dedup synthetics only when they are + # referenced as [all_follow] targets. stale locks left after hand-editing + # pins.toml are ignored, and can be cleaned with `tack rm `. + autoTargets = listToAttrs ( + map (target: { + name = target; + value = true; + }) (attrValues all_follow) + ); + autoNames = filter (n: !(declared ? ${n}) && autoTargets ? ${n}) (attrNames lock); + autoPin = + name: + let + sourceInfo = fetchPin name; + in + if pathExists (sourceInfo.outPath + "/flake.nix") then evalTopFlake sourceInfo { } else sourceInfo; + + self = + (mapAttrs loadPin declared) + // listToAttrs ( + map (name: { + inherit name; + value = autoPin name; + }) autoNames + ) + // overrides; + in + self // { __functor = _: call; }; +in +call { } diff --git a/.tack/pins.lock.json b/.tack/pins.lock.json new file mode 100644 --- /dev/null +++ b/.tack/pins.lock.json @@ -0,0 +1,26 @@ +{ + "crane": { + "lastModified": 1780532242, + "narHash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=", + "owner": "ipetkov", + "repo": "crane", + "rev": "59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37", + "type": "github" + }, + "nixpkgs": { + "lastModified": 1780930886, + "narHash": "sha256-rppURzHviaQN131F+nLiLdGfcb0uCd9gGP0E5+iw9MI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8c3cede7ddc26bd659d2d383b5610efbd2c7a16e", + "type": "github" + }, + "rust-overlay": { + "lastModified": 1781147846, + "narHash": "sha256-hBdiQYd40xRtBWBiXHUxuQYWmJBiK19YO1FiYgrmEo0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "107c334f141854f563f8adf1db781dc453d92639", + "type": "github" + } +} diff --git a/.tack/pins.toml b/.tack/pins.toml new file mode 100644 --- /dev/null +++ b/.tack/pins.toml @@ -0,0 +1,35 @@ +# tack pins. edit by hand or with tack add / rm / alias +# nix reads pins.lock.json; this file drives tack update + +# shorturl schemes. scheme:rest expands rest into {path} +[shorturls] +# gh = "github:{path}" + +# all_follow: input name -> top-level pin it follows wherever it appears +# opt out per-input with exclude_follow +[all_follow] +# nixpkgs = "nixpkgs" +# nixpkgs = ["nixpkgs-stable", "nixpkgs-unstable"] + +# [inputs.] fields +# url required, shorturl ok; ?rev= pins an exact commit +# type flake (default), fetch, or fixed +# flake legacy false means type = "fetch" +# follows { child = "pin" } override map +# exclude_follow all_follow names to skip +# dir subdir holding flake.nix +# submodules fetch git submodules +# unpack fixed-only: tarball or file +[inputs] + +[inputs.nixpkgs] +url = "github:NixOS/nixpkgs/nixpkgs-unstable" +type = "fetch" + +[inputs.rust-overlay] +url = "github:oxalica/rust-overlay/master" +type = "fetch" + +[inputs.crane] +url = "github:ipetkov/crane/master" +type = "fetch" diff --git a/nix/default.nix b/nix/default.nix --- a/nix/default.nix +++ b/nix/default.nix @@ -1,11 +1,11 @@ { system ? builtins.currentSystem, - sources ? import ../npins, - pkgs ? import sources.nixpkgs { + inputs ? import ../.tack, + pkgs ? import inputs.nixpkgs { inherit system; - overlays = [ (import sources.rust-overlay) ]; + overlays = [ (import inputs.rust-overlay) ]; }, - craneLib ? (import sources.crane { inherit pkgs; }).overrideToolchain ( + craneLib ? (import inputs.crane { inherit pkgs; }).overrideToolchain ( p: p.rust-bin.stable.latest.default ), }: diff --git a/npins/default.nix b/npins/default.nix deleted file mode 100644 --- a/npins/default.nix +++ /dev/null @@ -1,260 +0,0 @@ -/* - This file is provided under the MIT licence: - - 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: - - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - - 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. -*/ -# Generated by npins. Do not modify; will be overwritten regularly -let - # Backwards-compatibly make something that previously didn't take any arguments take some - # The function must return an attrset, and will unfortunately be eagerly evaluated - # Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments - mkFunctor = - fn: - let - e = builtins.tryEval (fn { }); - in - (if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; }; - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = - first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatStrings = builtins.concatStringsSep ""; - - # If the environment variable NPINS_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - # (Taken from Niv for compatibility) - mayOverride = - name: path: - let - envVarName = "NPINS_OVERRIDE_${saneName}"; - saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; - ersatz = builtins.getEnv envVarName; - in - if ersatz == "" then - path - else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" ( - if builtins.substring 0 1 ersatz == "/" then - /. + ersatz - else - /. + builtins.getEnv "PWD" + "/${ersatz}" - ); - - mkSource = - name: spec: - { - pkgs ? null, - }: - assert spec ? type; - let - # Unify across builtin and pkgs fetchers. - # `fetchGit` requires a wrapper because of slight API differences. - fetchers = - if pkgs == null then - { - inherit (builtins) fetchTarball fetchurl; - # Frustratingly, due to flakes and `fetchTree`, `fetchGit` - # has a different signature than the other builtin - # fetchers - fetchGit = args: (builtins.fetchGit args).outPath; - } - else - { - fetchTarball = - { - url, - sha256, - }: - pkgs.fetchzip { - inherit url sha256; - extension = "tar"; - }; - inherit (pkgs) fetchurl; - fetchGit = - { - url, - submodules, - rev, - name, - narHash, - }: - pkgs.fetchgit { - inherit url rev name; - fetchSubmodules = submodules; - hash = narHash; - }; - }; - - path = - if spec.type == "Git" then - mkGitSource fetchers spec - else if spec.type == "GitRelease" then - mkGitSource fetchers spec - else if spec.type == "PyPi" then - mkPyPiSource fetchers spec - else if spec.type == "Channel" then - mkChannelSource fetchers spec - else if spec.type == "Url" || spec.type == "MutableUrl" then - mkUrlSource fetchers spec - else if spec.type == "Container" then - mkContainerSource pkgs spec - else - builtins.throw "Unknown source type ${spec.type}"; - in - spec // { outPath = mayOverride name path; }; - - mkGitSource = - { - fetchTarball, - fetchGit, - ... - }: - { - repository, - revision, - url ? null, - submodules, - hash, - ... - }: - assert repository ? type; - # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository - # In the latter case, there we will always be an url to the tarball - if url != null && !submodules then - fetchTarball { - inherit url; - sha256 = hash; - } - else - let - url = - if repository.type == "Git" then - repository.url - else if repository.type == "GitHub" then - "https://github.com/${repository.owner}/${repository.repo}.git" - else if repository.type == "GitLab" then - "${repository.server}/${repository.repo_path}.git" - else if repository.type == "Forgejo" then - "${repository.server}/${repository.owner}/${repository.repo}.git" - else - throw "Unrecognized repository type ${repository.type}"; - urlToName = - url: rev: - let - matched = builtins.match "^.*/([^/]*)(\\.git)?$" url; - - short = builtins.substring 0 7 rev; - - appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; - in - "${if matched == null then "source" else builtins.head matched}${appendShort}"; - name = urlToName url revision; - in - fetchGit { - rev = revision; - narHash = hash; - - inherit name submodules url; - }; - - mkPyPiSource = - { fetchurl, ... }: - { - url, - hash, - ... - }: - fetchurl { - inherit url; - sha256 = hash; - }; - - mkChannelSource = - { fetchTarball, ... }: - { - url, - hash, - ... - }: - fetchTarball { - inherit url; - sha256 = hash; - }; - - mkUrlSource = - { - fetchTarball, - fetchurl, - ... - }: - { - url, - hash, - unpack, - ... - }: - (if unpack then fetchTarball else fetchurl) { - inherit url; - sha256 = hash; - }; - - mkContainerSource = - pkgs: - { - image_name, - image_tag, - image_digest, - hash, - ... - }@args: - if pkgs == null then - builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers" - else - pkgs.dockerTools.pullImage ( - { - imageName = image_name; - imageDigest = image_digest; - finalImageTag = image_tag; - hash = hash; - } - // (if args.arch or null != null then { arch = args.arch; } else { }) - ); - -in -mkFunctor ( - { - input ? ./sources.json, - }: - let - data = - if builtins.isPath input then - # while `readFile` will throw an error anyways if the path doesn't exist, - # we still need to check beforehand because *our* error can be caught but not the one from the builtin - # See: - if builtins.pathExists input then - builtins.fromJSON (builtins.readFile input) - else - throw "Input path ${toString input} does not exist" - else if builtins.isAttrs input then - input - else - throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset"; - version = data.version; - in - if version == 8 then - builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins - else - throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" -) diff --git a/npins/sources.json b/npins/sources.json deleted file mode 100644 --- a/npins/sources.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "pins": { - "crane": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "ipetkov", - "repo": "crane" - }, - "branch": "master", - "submodules": false, - "revision": "59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37", - "url": "https://github.com/ipetkov/crane/archive/59a82a1222dd3b2080b5cc52a1a2e8d5f1b77f37.tar.gz", - "hash": "sha256-D+BsdpxmtUwtqGoY0IXPhHgTlmqgcZKCEo1oMyn7ep0=" - }, - "nixpkgs": { - "type": "Channel", - "name": "nixpkgs-unstable", - "artifact": "nixexprs.tar.xz", - "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1009182.ffa10e26ae11/nixexprs.tar.xz", - "hash": "sha256-JX05Ms/dk0c+UoW9IqQriB53HNZFckX9Qd3EJqmcqEw=" - }, - "rust-overlay": { - "type": "Git", - "repository": { - "type": "GitHub", - "owner": "oxalica", - "repo": "rust-overlay" - }, - "branch": "master", - "submodules": false, - "revision": "27b7e78c6935293ee868469cc4172e9b8b17823b", - "url": "https://github.com/oxalica/rust-overlay/archive/27b7e78c6935293ee868469cc4172e9b8b17823b.tar.gz", - "hash": "sha256-4+8gPeiPeud89mjo865RwpqmKwa1MThRsq2SvRxo7mg=" - } - }, - "version": 8 -} diff --git a/book/src/nixos.md b/book/src/nixos.md --- a/book/src/nixos.md +++ b/book/src/nixos.md @@ -4,13 +4,13 @@ ## Setup -If you're using Nix Flakes for your system, you can install the NixOS service like so: +If you're using Nix flakes for your system, you can install the NixOS service like so: ```nix { inputs = { # ... - sandhole.url = "github:EpicEric/sandhole"; + sandhole.url = "github:EpicEric/sandhole/main"; }; outputs = @@ -42,7 +42,7 @@ let # ... - # Add admin keys to this directory + # Add admin keys to this link farm adminKeys = pkgs.linkFarm "sandhole-admin-keys" [ { name = "example-admin.pub"; @@ -52,7 +52,7 @@ } ]; - # Add user keys to this directory + # Add user keys to this link farm userKeys = pkgs.linkFarm "sandhole-user-keys" [ { name = "example-user.pub"; @@ -66,11 +66,11 @@ user-keys-directory = "/etc/sandhole/user-keys"; certificates-directory = "/var/lib/sandhole/certificates"; in - { # ... - # By symlinking to /etc, Sandhole doesn't have to restart when modifying keys + # By symlinking the SSH key directories to /etc, + # Sandhole doesn't have to restart when modifying keys environment.etc = { "sandhole/admin-keys".source = adminKeys; "sandhole/user-keys".source = userKeys; @@ -136,14 +136,13 @@ lib, ... }: - { # ... networking.nat = { enable = true; internalInterfaces = ["ve-+"]; - externalInterface = "eno0"; # Change to the appropriate interface + externalInterface = "eno0"; # Change to the appropriate WAN interface enableIPv6 = true; }; @@ -205,6 +204,9 @@ In order to avoid re-building Sandhole for each update, you can use Sandhole's binary cache. In `configuration.nix`: ```nix +{ + # ... + nix.settings = { substituters = [ "https://sandhole.cachix.org" @@ -213,4 +215,5 @@ "sandhole.cachix.org-1:cZadr6kgjQcRvsr++Nv9kgtMOrbLahiZBpuI9WpIXvA=" ]; }; +} ```