Skip to content

Commit

Permalink
dark era dont look
Browse files Browse the repository at this point in the history
Signed-off-by: saygo-png <[email protected]>
  • Loading branch information
saygo-png committed Nov 7, 2024
1 parent e92c3ee commit d268c8c
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 45 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
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
12 changes: 1 addition & 11 deletions .envrc
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
24 changes: 24 additions & 0 deletions ci/default.nix
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;
}
14 changes: 14 additions & 0 deletions ci/pinned-nixpkgs-for-nixshell.json
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="
}
}
54 changes: 54 additions & 0 deletions ci/update-shell-lock.sh
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"
72 changes: 38 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,44 @@
};

devShells = inputs.nixpkgs.lib.genAttrs ["x86_64-linux"] (system: {
default = let
pkgs = inputs.nixpkgs.legacyPackages.${system};
in
inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
(_: {
packages = [
pkgs.cargo
];

languages = {
nix.enable = true;
shell.enable = true;
};

pre-commit.hooks = {
commitlint-rs = {
enable = true;
entry = "commitlint --edit";
language = "rust";
package = pkgs-unstable.commitlint-rs;
pass_filenames = false;
stages = ["commit-msg"];
};
deadnix.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
# statix.enable = true;
alejandra.enable = true;
};
})
];
};
default = import ./shell.nix {inherit system;};
# let
# pkgs = inputs.nixpkgs.legacyPackages.${system};
# in
# inputs.devenv.lib.mkShell {
# inherit inputs pkgs;
# modules = [
# (_: {
# # packages = [
# # pkgs.cargo
# # ];
#
# languages = {
# nix.enable = true;
# shell.enable = true;
# };
#
# pre-commit.hooks = {
# commitlint-rs = {
# enable = true;
# entry = "commitlint --edit";
# language = "rust";
# package = pkgs-unstable.commitlint-rs;
# pass_filenames = false;
# fail_fast = true;
# stages = ["commit-msg"];
# extraPackages = [pkgs.cargo];
# };
# deadnix.enable = true;
# shellcheck.enable = true;
# # statix.enable = true;
# treefmt.settings.formatters = [
# pkgs.alejandra
# ];
# };
# })
# ];
# };
});
};
}
32 changes: 32 additions & 0 deletions shell.nix
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
];
}

0 comments on commit d268c8c

Please sign in to comment.