Create flake.nix

This commit is contained in:
jD91mZM2 2020-10-23 16:48:17 +02:00
parent 5eb0cbe93b
commit f8b23a0dd6
No known key found for this signature in database
GPG Key ID: E471B167937421AB
6 changed files with 72 additions and 16 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
eval "$(lorri direnv)"

View File

@ -1,14 +1,3 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
name = "nixos-generators";
src = lib.cleanSource ./.;
meta.description = "Collection of image builders";
nativeBuildInputs = [ makeWrapper ];
installFlags = [ "PREFIX=$(out)" ];
postFixup = ''
wrapProgram $out/bin/nixos-generate \
--prefix PATH : ${lib.makeBinPath [ jq coreutils findutils nix ] }
'';
}
(import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).defaultNix.default

24
flake.lock Normal file
View File

@ -0,0 +1,24 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1603066386,
"narHash": "sha256-BpO5yrRi2oqYaOHwWZBoRlLydOeYm0YhuLG4ISsaSzE=",
"path": "/nix/store/6mz8x91y5pbndzfcbiwf3ag8k30k6m00-source",
"rev": "5265d49a36bb5a18c85e6817b338b456acc3b8cc",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@ -0,0 +1,40 @@
{
description = "nixos-generators - one config, multiple formats";
outputs = { self, nixpkgs }: let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" ];
in {
# Packages
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages."${system}";
in {
nixos-generators = pkgs.stdenv.mkDerivation {
name = "nixos-generators";
src = ./.;
meta.description = "Collection of image builders";
nativeBuildInputs = with pkgs; [ makeWrapper ];
installFlags = [ "PREFIX=$(out)" ];
postFixup = ''
wrapProgram $out/bin/nixos-generate \
--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ jq coreutils findutils nix ])}
'';
};
});
defaultPackage = forAllSystems (system: self.packages."${system}".nixos-generators);
devShell = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages."${system}";
in pkgs.mkShell {
buildInputs = with pkgs; [ jq coreutils findutils nix ];
});
# Make it runnable with `nix app`
apps = forAllSystems (system: {
nixos-generators = {
type = "app";
program = "${self.packages."${system}".nixos-generators}/bin/nixos-generators";
};
});
defaultApp = forAllSystems (system: self.apps."${system}".nixos-generators);
};
}

View File

@ -1,5 +1,4 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p jq
#!/usr/bin/env bash
set -euo pipefail
## Configuration

3
shell.nix Normal file
View File

@ -0,0 +1,3 @@
(import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix.default