>_ Replaced shell scripts with justfile, nix shell to download the rest

This commit is contained in:
Martin Berg Alstad 2025-02-13 21:52:01 +01:00
parent 0b0d93cf41
commit 0825b293a1
Signed by: martials
GPG Key ID: 706F53DD087A91DE
9 changed files with 48 additions and 32 deletions

View File

@ -21,12 +21,19 @@ Requires Nix-channel with [NixOS 24.11](https://nixos.org/)
## Commands
Scripts will not run unless the necessary packages have been added to the path, either in a shell or by running nixos-rebuild
First time run, will create a shell with the minimum dependencies in order to download the rest
```Shell
nix develop . --experimental-features 'nix-command flakes'
just switch-now
```
Scripts below will not run unless the necessary packages have been added to the path, either in a shell or by running nixos-rebuild
Format all .nix files
```Shell
./fmt
just fmt
```
Rebuild and test Nix configuration
@ -34,7 +41,7 @@ Rebuild and test Nix configuration
- Will add all new files to git and format all nix-files
```Shell
./test
just test
```
Rebuild and switch Nix configuration
@ -42,7 +49,7 @@ Rebuild and switch Nix configuration
- Will add all new files to git and format all nix-files
```Shell
./rebuild
just switch
```
Update and switch
@ -50,5 +57,5 @@ Update and switch
- Will update the flakes and nix-channel, then switch if there are no errors
```Shell
./update
just update
```

View File

@ -37,14 +37,23 @@
}:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
inherit (self) outputs;
common = import ./common.nix;
in
{
defaultPackage.${system} = home-manager.defaultPackage.${system};
# The minimum amount of dependencies in order to run 'just switch-now'
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
just
nh
];
};
# Adds the nix fmt command to format nix files
formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style;
formatter.${system} = pkgs.nixfmt-rfc-style;
nixosConfigurations.${common.hostname} = nixpkgs.lib.nixosSystem {
system = system;

5
fmt
View File

@ -1,5 +0,0 @@
#!/usr/bin/env sh
# Format all files matched by treefmt.toml
treefmt --on-unmatched info

View File

@ -11,6 +11,7 @@
"toml"
"nix"
"git-firefly"
"just"
];
userSettings =
let

24
justfile Normal file
View File

@ -0,0 +1,24 @@
default:
@just --list
fmt:
treefmt --on-unmatched info
test *FLAGS:
git add .
just fmt
nh os test . {{FLAGS}}
switch *FLAGS:
git add .
just fmt
nh os switch . {{FLAGS}}
switch-now *FLAGS:
nh os switch . {{FLAGS}}
update:
nix-channel --update
nix flake update
just switch

View File

@ -14,6 +14,7 @@
rustup
nodejs_22
pnpm
just
gcc # Required for C, Rust and others
# Language servers
nixd

9
switch
View File

@ -1,9 +0,0 @@
#!/usr/bin/env sh
# Accepts all arguments to nh os switch
# For example --ask to prompt if the user want to switch configs
# Rebuild and switch the environment if successful
git add .
./fmt
nh os switch . "$@"

6
test
View File

@ -1,6 +0,0 @@
#!/usr/bin/env sh
# Rebuild and switch the environment if successful
git add .
./fmt
nh os test . "$@"

6
update
View File

@ -1,6 +0,0 @@
#!/usr/bin/env sh
nix-channel --update
nix flake update
./switch