Skip to content

Commit

Permalink
shell: implement flk as devshell module
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arnold committed Dec 29, 2020
1 parent 37d40e0 commit d316304
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 69 deletions.
71 changes: 2 additions & 69 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,6 @@ let
devshell' = fetch "devshell";
pkgs' = import devshell' { inherit nixpkgs; };
in
{ pkgs ? pkgs', ... }:
let
configs = "${toString ./.}#nixosConfigurations";
build = "config.system.build";

installPkgs = (import "${nixpkgs}/nixos" {
configuration = { };
system = pkgs.system;
}).config.system.build;

flk = pkgs.writeShellScriptBin "flk" ''
if [[ -z "$1" || "$1" == "help" || "--help" || "-h" ]]; then
echo "Usage: $(basename "$0") [ iso | install {host} | {host} [switch|boot|test] ]"
elif [[ "$1" == "iso" ]]; then
nix build ${configs}.niximg.${build}.isoImage
elif [[ "$1" == "install" ]]; then
sudo nixos-install --flake ".#$2" "${"\${@:3}"}"
else
sudo nixos-rebuild --flake ".#$1" "${"\${@:2}"}"
fi
'';

name = "flk";
in
pkgs.mkDevShell {
inherit name;

packages = with pkgs; with installPkgs; [
git-crypt
nixos-install
nixos-generate-config
nixos-enter
];

env = { inherit name; };

commands = with pkgs; [
{
name = nixpkgs-fmt.pname;
package = nixpkgs-fmt;
help = nixpkgs-fmt.meta.description;
category = "linters";
}
{
name = flk.name;
help = "Build, deploy, and install nixflk";
category = "main";
package = flk;
}
{
name = "grip";
help = python38Packages.grip.meta.description;
category = "servers";
package = python38Packages.grip;
}
{
name = git.pname;
help = git.meta.description;
category = "vcs";
package = git;
}
{
name = "nix";
help = nixFlakes.meta.description;
category = "main";
command = ''${nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"'';
}
];

{ pkgs ? pkgs', ... }: pkgs.mkDevShell {
imports = [ (import ./shells/flk) ];
}
74 changes: 74 additions & 0 deletions shells/flk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{ config, lib, pkgs, ... }: {
config = let
nixpkgs = import ../../compat/nixpkgs.nix;
configs = "${toString ../..}#nixosConfigurations";
build = "config.system.build";

installPkgs = (
import "${nixpkgs}/nixos" {
configuration = {};
system = pkgs.system;
}
).config.system.build;

flk = pkgs.writeShellScriptBin "flk" ''
if [[ -z "$1" || "$1" == "help" || "--help" || "-h" ]]; then
echo "Usage: $(basename "$0") [ iso | install {host} | {host} [switch|boot|test] ]"
elif [[ "$1" == "iso" ]]; then
nix build ${configs}.niximg.${build}.isoImage
elif [[ "$1" == "install" ]]; then
sudo nixos-install --flake ".#$2" "${"\${@:3}"}"
else
sudo nixos-rebuild --flake ".#$1" "${"\${@:2}"}"
fi
'';

name = "flk";
in
{
inherit name;

packages = with pkgs; with installPkgs; [
git-crypt
nixos-install
nixos-generate-config
nixos-enter
];

env = { inherit name; };

commands = with pkgs; [
{
name = nixpkgs-fmt.pname;
package = nixpkgs-fmt;
help = nixpkgs-fmt.meta.description;
category = "linters";
}
{
name = flk.name;
help = "Build, deploy, and install nixflk";
category = "main";
package = flk;
}
{
name = "grip";
help = python38Packages.grip.meta.description;
category = "servers";
package = python38Packages.grip;
}
{
name = git.pname;
help = git.meta.description;
category = "vcs";
package = git;
}
{
name = "nix";
help = nixFlakes.meta.description;
category = "main";
command = ''${nixFlakes}/bin/nix --option experimental-features "nix-command flakes ca-references" "$@"'';
}
];

};
}

0 comments on commit d316304

Please sign in to comment.