Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose flk devshell module #55

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
inherit (nixos) lib;
inherit (lib) recursiveUpdate filterAttrs mapAttrs;
inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules
genPackages pkgImport;
genPackages pkgImport devshells;

utils = import ./lib/utils.nix { inherit lib; };

Expand Down Expand Up @@ -52,6 +52,8 @@

nixosModules = modules;

devshellModules = devshells;

templates.flk.path = ./.;

templates.flk.description = "flk template";
Expand Down
7 changes: 7 additions & 0 deletions lib/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ in
(recursiveUpdate cachixAttrs modulesAttrs)
profilesAttrs;

devshells =
let
# shells
shellList = import ../shells/list.nix;
in
pathsToImportedAttrs shellList;

genPackages = { self, pkgs }:
let
inherit (self) overlay overlays;
Expand Down
77 changes: 2 additions & 75 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +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" ]]; 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
pre-commit
];

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 = "hooks";
help = "install git hooks";
command = "pre-commit install";
}
{
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) ];
}
80 changes: 80 additions & 0 deletions shells/flk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }: {
config = let
nixpkgs = import ../../compat/nixpkgs.nix;
blaggacao marked this conversation as resolved.
Show resolved Hide resolved
configs = "${toString ../..}#nixosConfigurations";
blaggacao marked this conversation as resolved.
Show resolved Hide resolved
build = "config.system.build";

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

flk = pkgs.writeShellScriptBin "flk" ''
if [[ -z "$1" ]]; 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
pre-commit
];

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 = "hooks";
help = "install git hooks";
command = "pre-commit install";
}
{
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" "$@"'';
}
];

};
}
3 changes: 3 additions & 0 deletions shells/list.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
./flk
]