refactor nix flake

This commit is contained in:
Julie B. 2022-04-23 13:41:43 +02:00
parent 95371a5f8e
commit f6a6ca3c79
8 changed files with 86 additions and 32 deletions

2
.envrc
View File

@ -1,2 +1,2 @@
watch_file devshell.toml
use flake || use nix
watch_file flake.nix nix/devshell.*

View File

@ -1 +1,2 @@
(import lib/compat.nix).defaultNix
# This file allows nix-build to find the flake
(import nix/flake-compat.nix).defaultNix

View File

@ -15,13 +15,29 @@
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1623875721,
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
"type": "github"
},
"original": {
@ -30,6 +46,25 @@
"type": "github"
}
},
"fup": {
"inputs": {
"flake-utils": "flake-utils"
},
"locked": {
"lastModified": 1638172912,
"narHash": "sha256-jxhQGNEsZTdop/Br3JPS+xmBf6t9cIWRzVZFxbT76Rw=",
"owner": "gytis-ivaskevicius",
"repo": "flake-utils-plus",
"rev": "166d6ebd9f0de03afc98060ac92cba9c71cfe550",
"type": "github"
},
"original": {
"owner": "gytis-ivaskevicius",
"ref": "v1.3.1",
"repo": "flake-utils-plus",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1624553300,
@ -47,7 +82,8 @@
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils",
"flake-compat": "flake-compat",
"fup": "fup",
"nixpkgs": "nixpkgs"
}
}

View File

@ -12,33 +12,45 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# The flake file is the entry point for nix commands
{
description = "guest NixOS images with minimal footprint";
# Inputs are how Nix can use code from outside the flake during evaluation.
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.fup.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.3.1";
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;
outputs = inputs@{ self, nixpkgs, devshell, flake-utils }:
with flake-utils.lib;
let
overlay = import tool/overlay.nix;
in
{
nixosModules.core = import ./core;
nixosModules.declarative = import ./declarative inputs;
inherit overlay;
defaultTemplate = {
description = "Example guest configurations";
path = ./template;
# Outputs are the public-facing interface to the flake.
outputs = inputs@{ self, devshell, fup, nixpkgs, ... }: fup.lib.mkFlake {
inherit self inputs;
sharedOverlays = [
devshell.overlay
self.overlay
];
overlay = import tool/overlay.nix;
nixosModules.core = import ./core;
nixosModules.declarative = import ./declarative inputs;
defaultTemplate = {
description = "Example guest configurations";
path = ./template;
};
outputsBuilder = channels: rec {
packages = rec {
inherit (channels.nixpkgs) miniguest;
default = miniguest;
};
} // eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
in
{
packages.miniguest = pkgs.miniguest;
defaultPackage = pkgs.miniguest;
defaultApp = mkApp { drv = pkgs.miniguest; };
devShell = devshell.legacyPackages.${system}.fromTOML ./devshell.toml;
checks = import ./checks inputs system;
});
defaultPackage = packages.default;
defaultApp = fup.lib.mkApp { drv = packages.default; };
devShell = channels.nixpkgs.callPackage nix/devshell.nix { };
checks = import ./checks inputs channels.nixpkgs.system;
};
};
}

3
nix/devshell.nix Normal file
View File

@ -0,0 +1,3 @@
{ devshell }:
devshell.fromTOML ./devshell.toml

View File

@ -1,8 +1,9 @@
let
rev = "99f1c2157fba4bfe6211a321fd0ee43199025dbf";
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
inherit (lock.nodes.flake-compat.locked) rev narHash;
flake-compat = fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
sha256 = narHash;
};
in
import flake-compat { src = ./..; }

View File

@ -1 +1,2 @@
(import lib/compat.nix).shellNix
# This file allows nix-shell to find the flake
(import nix/flake-compat.nix).shellNix