Skip to content

Commit

Permalink
Improve devshells
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonbeck committed Oct 24, 2024
1 parent aafd2bb commit 6de0a59
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
uses: cachix/install-nix-action@v27
- name: Check formatting
run: |
nix develop .#formatting --command check-formatting
nix develop .#formatting --command check formatting
46 changes: 33 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,46 @@
in {
default = pkgs.mkShell {
inputsFrom = with self.devShells.${system}; [
building
managing-secrets
formatting
editing
];
building
managing-secrets
formatting
editing
];
};
building = pkgs.mkShell {
packages = [
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
nix-darwin.packages.${system}.default
];
packages =
[
(pkgs.writeScriptBin "update" ''
nix flake update
'')
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
nix-darwin.packages.${system}.default
(pkgs.writeScriptBin "rebuild" ''
darwin-rebuild switch --flake .#"$1"
'')
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
nix-darwin.packages.${system}.default
(pkgs.writeScriptBin "rebuild" ''
nixos-rebuild switch --flake .#"$1"
'')
];
};
formatting = pkgs.mkShell {
packages = [
(treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} ./treefmt.nix).config.build.wrapper
(pkgs.writeScriptBin "check-formatting" ''
treefmt --fail-on-change
(pkgs.writeScriptBin "check" ''
if [ "$1" == "formatting" ]; then
echo "Checking formatting..."
treefmt --fail-on-change
fi
'')
(pkgs.writeScriptBin "apply-formatting" ''
treefmt
(pkgs.writeScriptBin "apply" ''
if [ "$1" == "formatting" ]; then
echo "Applying formatting..."
treefmt
fi
'')
];
};
Expand Down

0 comments on commit 6de0a59

Please sign in to comment.