Skip to content

Commit

Permalink
Create flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
jD91mZM2 committed Oct 23, 2020
1 parent 5eb0cbe commit f8b23a0
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 16 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eval "$(lorri direnv)"
17 changes: 3 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 24 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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);
};
}
3 changes: 1 addition & 2 deletions nixos-generate
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p jq
#!/usr/bin/env bash
set -euo pipefail

## Configuration
Expand Down
3 changes: 3 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(import (builtins.fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix.default

0 comments on commit f8b23a0

Please sign in to comment.