-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: saygo-png <[email protected]>
- Loading branch information
Showing
7 changed files
with
173 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,2 @@ | ||
# shellcheck disable=SC2148 | ||
|
||
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" | ||
fi | ||
|
||
watch_file flake.nix | ||
watch_file flake.lock | ||
|
||
if ! use flake . --impure; then | ||
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 | ||
fi | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
let | ||
pinnedNixpkgs = builtins.fromJSON (builtins.readFile ./pinned-nixpkgs.json); | ||
in | ||
{ | ||
system ? builtins.currentSystem, | ||
nixpkgs ? null, | ||
}: let | ||
nixpkgs' = | ||
if nixpkgs == null | ||
then | ||
fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/archive/${pinnedNixpkgs.rev}.tar.gz"; | ||
sha256 = pinnedNixpkgs.sha256; | ||
} | ||
else nixpkgs; | ||
|
||
pkgs = import nixpkgs' { | ||
inherit system; | ||
config = {}; | ||
overlays = []; | ||
}; | ||
in { | ||
inherit pkgs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"nixpkgs": { | ||
"rev": "9201b5ff357e781bf014d0330d18555695df7ba8", | ||
"sha256": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=" | ||
}, | ||
"nixpkgs-unstable": { | ||
"rev": "4c2fcb090b1f3e5b47eaa7bd33913b574a11e0a0", | ||
"sha256": "sha256-/uilDXvCIEs3C9l73JTACm4quuHUsIHcns1c+cHUJwA=" | ||
}, | ||
"devenv": { | ||
"rev": "c5353d1a0483b8f0dc15933de91c6b1b9a892831", | ||
"sha256": "sha256-ogmpmsPOlX4qeWVW4NZkTd0Lx8V4rvnjwlgOX7WnTZo=" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit on error, undefined variables, and pipe failures | ||
set -euo pipefail | ||
|
||
INPUT_FILE="../flake.lock" | ||
OUTPUT_FILE="pinned-nixpkgs-for-nixshell.json" | ||
|
||
# Check if input file exists | ||
if [[ ! -f "$INPUT_FILE" ]]; then | ||
echo "Error: Input file '$INPUT_FILE' not found" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Check if input file is readable | ||
if [[ ! -r "$INPUT_FILE" ]]; then | ||
echo "Error: Input file '$INPUT_FILE' is not readable" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Check if output directory is writable | ||
if [[ ! -w "$(dirname "$OUTPUT_FILE")" ]]; then | ||
echo "Error: Directory '$(dirname "$OUTPUT_FILE")' is not writable" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Check if the input file contains valid JSON | ||
if ! jq empty "$INPUT_FILE" 2>/dev/null; then | ||
echo "Error: Input file '$INPUT_FILE' is not valid JSON" >&2 | ||
exit 1 | ||
fi | ||
|
||
# If all checks pass, create the output file | ||
jq ' | ||
. as $root | | ||
["nixpkgs", "nixpkgs-unstable", "devenv"] as $packages | | ||
reduce $packages[] as $pkg ({}; | ||
. + { | ||
($pkg): { | ||
rev: $root.nodes[$pkg].locked.rev, | ||
sha256: $root.nodes[$pkg].locked.narHash | ||
} | ||
} | ||
) | ||
' "$INPUT_FILE" >"$OUTPUT_FILE" | ||
|
||
# Verify the output is valid JSON | ||
if ! jq empty "$OUTPUT_FILE" 2>/dev/null; then | ||
echo "Error: Failed to create valid JSON output" >&2 | ||
rm -f "$OUTPUT_FILE" # Clean up invalid output | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully created $OUTPUT_FILE with pinned package information" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# From nixpkgs shell.nix | ||
# Note: We intentionally don't use Flakes here, | ||
# because every time you change any file and do another `nix develop`, | ||
# it would create another copy of the entire ~500MB tree in the store. | ||
# See https://github.com/NixOS/nix/pull/6530 for the future | ||
{ | ||
system ? builtins.currentSystem, | ||
nixpkgs ? null, | ||
}: let | ||
pinnedNixpkgs = builtins.fromJSON (builtins.readFile ./ci/pinned-nixpkgs-for-nixshell.json); | ||
nixpkgs' = | ||
if nixpkgs == null | ||
then | ||
fetchTarball { | ||
url = "https://github.com/NixOS/nixpkgs/archive/${pinnedNixpkgs.nixpkgs.rev}.tar.gz"; | ||
sha256 = pinnedNixpkgs.nixpkgs.sha256; | ||
} | ||
else nixpkgs; | ||
|
||
pkgs = import nixpkgs' { | ||
inherit system; | ||
config = {}; | ||
overlays = []; | ||
}; | ||
in | ||
pkgs.mkShell { | ||
packages = [ | ||
pkgs.devenv | ||
pkgs.hello | ||
pkgs.pridefetch | ||
]; | ||
} |