Skip to content

Commit

Permalink
refactor: update build scripts and flake configurations
Browse files Browse the repository at this point in the history
- Removed `temp_dir` variable and cleaned up build scripts in `justfile`.
- Updated `build-template` to use `mktemp` for temporary directories.
- Added `set -euxo pipefail` to ensure scripts fail on errors.
- Modified `build-darwin`, `build-home-manager`, `build-language`, `build-nixos-desktop`, and `build-nixos-minimal` to use the new `build-template` logic.
- Reordered fields in `template/haskell/flake.nix` for consistency.
- Removed `nodejs` inheritance in `template/vite-react/flake.nix` and cleaned up package definition.
  • Loading branch information
erikreinert committed Jun 3, 2024
1 parent fb1fc56 commit b42f706
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
59 changes: 38 additions & 21 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,52 @@
temp_dir := "/tmp/kickstart.nix"

_default:
just --list

build profile:
nix build --json --no-link --print-build-logs "{{ profile }}"
nix build --json --no-link --print-build-logs "{{ profile }}" \
| jq -r ".[0].outputs.out"

check:
nix flake check

clean-template template:
rm -rf {{ temp_dir }}/{{ template }}
mkdir -p {{ temp_dir }}/{{ template }}

build-template template: (clean-template template)
build-template template:
#!/usr/bin/env bash
DERIVATION=$(just build ".#example-{{ template }}")
OUTPUT=$(echo $DERIVATION | jq -r ".[0].outputs.out")
cp --no-preserve=mode -r $OUTPUT/* {{ temp_dir }}/{{ template }}
set -euxo pipefail
OUTPUT_DIR=$(just build "$PWD#example-{{ template }}")
TEMP_DIR=$(mktemp -d)
cp --no-preserve=mode -r $OUTPUT_DIR/* $TEMP_DIR/.
echo $TEMP_DIR
build-darwin system="x86_64": (build-template "darwin")
just build "{{ temp_dir }}/darwin#darwinConfigurations.{{ system }}.config.system.build.toplevel"
build-darwin system="x86_64":
#!/usr/bin/env bash
set -euxo pipefail
TEMP_DIR=$(just build-template "darwin")
ls -alh $TEMP_DIR
just build "$TEMP_DIR#darwinConfigurations.{{ system }}.config.system.build.toplevel"
build-home-manager system="x86_64-linux": (build-template "home-manager")
just build "{{ temp_dir }}/home-manager#homeConfigurations.{{ system }}.activationPackage"
build-home-manager system="x86_64-linux":
#!/usr/bin/env bash
set -euxo pipefail
TEMP_DIR=$(just build-template "home-manager")
ls -alh $TEMP_DIR
just build "$TEMP_DIR#homeConfigurations.{{ system }}.activationPackage"
build-language template profile="default": (build-template template)
just build "{{ temp_dir }}/{{ template }}#{{ profile }}"
build-language language profile="default":
#!/usr/bin/env bash
set -euxo pipefail
TEMP_DIR=$(just build-template "{{ language }}")
ls -alh $TEMP_DIR
just build "$TEMP_DIR"
build-nixos-desktop system="x86_64" desktop="gnome": (build-template 'nixos-desktop-'+desktop)
just build "{{ temp_dir }}/nixos-desktop-{{ desktop }}#nixosConfigurations.{{ system }}.config.system.build.toplevel"
build-nixos-desktop system="x86_64" desktop="gnome":
#!/usr/bin/env bash
set -euxo pipefail
TEMP_DIR=$(just build-template "nixos-desktop-{{ desktop }}")
ls -alh $TEMP_DIR
just build "$TEMP_DIR#nixosConfigurations.{{ system }}.config.system.build.toplevel"
build-nixos-minimal system="x86_64": (build-template "nixos-minimal")
just build "{{ temp_dir }}/nixos-minimal#nixosConfigurations.{{ system }}.config.system.build.toplevel"
build-nixos-minimal system="x86_64":
#!/usr/bin/env bash
set -euxo pipefail
TEMP_DIR=$(just build-template "nixos-minimal")
ls -alh $TEMP_DIR
just build "$TEMP_DIR#nixosConfigurations.{{ system }}.config.system.build.toplevel"
6 changes: 3 additions & 3 deletions template/haskell/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
};
packages = {
default = mkDerivation {
pname = name;
inherit version;
src = ./.;
license = "";
description = "";
license = "";
pname = name;
src = ./.;
};

docker = buildImage {
Expand Down
3 changes: 1 addition & 2 deletions template/vite-react/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
}: let
name = "example";
version = "0.1.0";
nodejs = pkgs.nodejs_21;
in {
devShells = {
default = pkgs.mkShell {
Expand All @@ -28,7 +27,7 @@

packages = {
default = pkgs.buildNpmPackage {
inherit version nodejs;
inherit version;
pname = name;
src = ./.;
npmDepsHash = "sha256-KeXRIp4qNywb1sy5lXTagoUsW6EeK1kF5OWJ97w9Vfk=";
Expand Down

0 comments on commit b42f706

Please sign in to comment.