From b1721e941bb94c6438e2dc155d1fca7495aa613d Mon Sep 17 00:00:00 2001 From: Evan Quiney Date: Wed, 1 Oct 2025 09:47:00 +0100 Subject: [PATCH] nix cleanup --- .envrc | 1 - .gitignore | 3 - flake.lock | 104 +++++++--------------------- flake.nix | 128 ++++++++++++++--------------------- justfile | 38 ----------- nix/modules/flake-root.nix | 20 ------ nix/modules/go-forwarder.nix | 19 ------ nix/modules/just-flake.nix | 26 ------- nix/modules/macmon.nix | 12 ---- nix/modules/pkgs-init.nix | 62 ----------------- nix/modules/python.nix | 20 ------ nix/modules/rust.nix | 25 ------- 12 files changed, 76 insertions(+), 382 deletions(-) delete mode 100644 nix/modules/flake-root.nix delete mode 100644 nix/modules/go-forwarder.nix delete mode 100644 nix/modules/just-flake.nix delete mode 100644 nix/modules/macmon.nix delete mode 100644 nix/modules/pkgs-init.nix delete mode 100644 nix/modules/python.nix delete mode 100644 nix/modules/rust.nix diff --git a/.envrc b/.envrc index 613b6c8d..3550a30f 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1 @@ use flake -# eval "$shellHook" # https://github.com/nix-community/nix-direnv/issues/109#issuecomment-992514426 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 12a0aec4..9f5c195a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,5 @@ dist/ .DS_Store */.DS_Store -# Says this symlink should be git-ignored https://github.com/juspay/just-flake -just-flake.just - # for the gitingest enthusiasts digest.txt diff --git a/flake.lock b/flake.lock index 35076eff..8559ca9e 100644 --- a/flake.lock +++ b/flake.lock @@ -21,87 +21,21 @@ "type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { + "flake-utils": { "inputs": { - "nixpkgs-lib": [ - "nixpkgs" - ] + "systems": "systems" }, "locked": { - "lastModified": 1754487366, - "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-root": { - "locked": { - "lastModified": 1723604017, - "narHash": "sha256-rBtQ8gg+Dn4Sx/s+pvjdq3CB2wQNzx9XGFq/JVGCB6k=", - "owner": "srid", - "repo": "flake-root", - "rev": "b759a56851e10cb13f6b8e5698af7b59c44be26e", - "type": "github" - }, - "original": { - "owner": "srid", - "repo": "flake-root", - "type": "github" - } - }, - "just-flake": { - "locked": { - "lastModified": 1713316411, - "narHash": "sha256-NkJfU6H+6vgHkPtZ2ESbZ/h2wnsDQrZvB4vbdUIBx8Q=", - "owner": "juspay", - "repo": "just-flake", - "rev": "0e33952a4bcd16cd54ee3aba8111606c237d4526", - "type": "github" - }, - "original": { - "owner": "juspay", - "repo": "just-flake", - "type": "github" - } - }, - "make-shell": { - "inputs": { - "flake-compat": "flake-compat" - }, - "locked": { - "lastModified": 1733933815, - "narHash": "sha256-9JjM7eT66W4NJAXpGUsdyAFXhBxFWR2Z9LZwUa7Hli0=", - "owner": "nicknovitski", - "repo": "make-shell", - "rev": "ffeceae9956df03571ea8e96ef77c2924f13a63c", - "type": "github" - }, - "original": { - "owner": "nicknovitski", - "repo": "make-shell", + "owner": "numtide", + "repo": "flake-utils", "type": "github" } }, @@ -124,10 +58,7 @@ "root": { "inputs": { "fenix": "fenix", - "flake-parts": "flake-parts", - "flake-root": "flake-root", - "just-flake": "just-flake", - "make-shell": "make-shell", + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } }, @@ -147,6 +78,21 @@ "repo": "rust-analyzer", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index b1f69a86..118fb97f 100644 --- a/flake.nix +++ b/flake.nix @@ -3,24 +3,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - - # Use flake-parts for modular configs - flake-parts = { - url = "github:hercules-ci/flake-parts"; - inputs.nixpkgs-lib.follows = "nixpkgs"; - }; - - # Flake-parts wrapper for mkShell - make-shell.url = "github:nicknovitski/make-shell"; - - # Provides path to project root with: - # 1. ${lib.getExe config.flake-root.package} - # 2. $FLAKE_ROOT environment-varible - flake-root.url = "github:srid/flake-root"; - - # Provides flake integration with [Just](https://just.systems/man/en/) - just-flake.url = "github:juspay/just-flake"; - + flake-utils.url = "github:numtide/flake-utils"; # Provides Rust dev-env integration: fenix = { url = "github:nix-community/fenix"; @@ -36,70 +19,61 @@ # }; outputs = - inputs@{ - flake-parts, - ... - }: - flake-parts.lib.mkFlake { inherit inputs; } ( - { flake-parts-lib, self, ... }: + inputs: + let + systems = [ + "x86_64-linux" + "aarch64-darwin" + ]; + in + inputs.flake-utils.lib.eachSystem systems ( + system: + let + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ inputs.fenix.overlays.default ]; + }; + in { - imports = [ - inputs.make-shell.flakeModules.default + devShells.default = pkgs.mkShell { + packages = + with pkgs; + [ + # PYTHON + python313 + uv + ruff + basedpyright - ./nix/modules/pkgs-init.nix # nixpkgs overlays manager - ./nix/modules/flake-root.nix - ./nix/modules/just-flake.nix - ./nix/modules/macmon.nix - ./nix/modules/python.nix - ./nix/modules/rust.nix - ./nix/modules/go-forwarder.nix - ]; - systems = [ - "x86_64-linux" - "aarch64-darwin" - ]; - perSystem = - { - config, - self', - inputs', - pkgs, - system, - ... - }: - { - # Per-system attributes can be defined here. The self' and inputs' - # module parameters provide easy access to attributes of the same - # system. - # NOTE: pkgs is equivalent to inputs'.nixpkgs.legacyPackages.hello; - apps = { }; + # RUST + (fenix.complete.withComponents [ + "cargo" + "rustc" + "clippy" + "rustfmt" + "rust-src" + ]) + rustup # Just here to make RustRover happy - make-shells.default = { - packages = [ - pkgs.protobuf - ]; + # NIX + nixpkgs-fmt + ] + ++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [ + # MACMON + macmon - nativeBuildInputs = with pkgs; [ - nixpkgs-fmt - ]; + # JUST + just + ]); - shellHook = '' - export GO_BUILD_DIR=$(git rev-parse --show-toplevel)/build; - export DASHBOARD_DIR=$(git rev-parse --show-toplevel)/dashboard; - ''; - - # Arguments which are intended to be environment variables in the shell environment - # should be changed to attributes of the `env` option - env = { }; - - # Arbitrary mkDerivation arguments should be changed to be attributes of the `additionalArguments` option - additionalArguments = { }; - }; - }; - flake = { - # The usual flake attributes can be defined here, including system- - # agnostic ones like nixosModule and system-enumerating ones, although - # those are more easily expressed in perSystem. + shellHook = '' + # PYTHON + export DASHBOARD_DIR=$(git rev-parse --show-toplevel)/dashboard; + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.python313}/lib + echo + echo "🍎🍎 Run 'just ' to get started" + just --list + ''; }; } diff --git a/justfile b/justfile index 1b84e2eb..98392578 100644 --- a/justfile +++ b/justfile @@ -1,17 +1,9 @@ -import 'just-flake.just' - -default: - @just --list - fmt: uv run ruff format src lint: uv run ruff check --fix src -lint-check: - uv run ruff check src - test: uv run pytest src @@ -23,33 +15,3 @@ sync: sync-clean: uv sync --all-packages --force-reinstall --no-cache - -build: - uv build --all-packages - -# Build the Go forwarder binary -build-forwarder: - HASH=$(uv run scripts/hashdir.py) && go build -C networking/forwarder -buildvcs=false -o $GO_BUILD_DIR/forwarder -ldflags "-X 'main.SourceHash=${HASH}'" - chmod 0755 $GO_BUILD_DIR/forwarder - -# Run forwarder tests -test-forwarder: - cd networking/forwarder && go test ./src/... - -# Build all components (Python packages and Go forwarder) -build-all: build build-forwarder - -run n="1" clean="false": - @echo "→ Spinning up {{n}} node(s) (clean={{clean}})" - if [ "{{clean}}" = "true" ]; then ./run.sh -c; else ./run.sh; fi - if [ "{{n}}" -gt 1 ]; then \ - for i in $(seq 2 "{{n}}"); do \ - if [ "{{clean}}" = "true" ]; then ./run.sh -rc; else ./run.sh -r; fi; \ - done; \ - fi - -# remote debugging auto-runner command: TODO: find better place to put this?? -# -> this pulls from upstream and wipes .exo folder, rebuilds & restarts -# -> TODO: maybe add a sync step for python deps ?? -autorun-master: - uv run scripts/watch-pull-restart.py --cmd "uv run exo-master" --restart-cmd "rm -rf ~/.exo && just build-forwarder" \ No newline at end of file diff --git a/nix/modules/flake-root.nix b/nix/modules/flake-root.nix deleted file mode 100644 index 6b000405..00000000 --- a/nix/modules/flake-root.nix +++ /dev/null @@ -1,20 +0,0 @@ -# Provides path to project root with: -# 1. ${lib.getExe config.flake-root.package} -# 2. $FLAKE_ROOT environment-varible - -# These values would bind to the consumer flake when this flake module is imported: -{ inputs, ... }: - -# The actual flake-parts module configuration -{ - imports = [ inputs.flake-root.flakeModule ]; - perSystem = - { config, ... }: - { - flake-root.projectRootFile = "flake.nix"; # Not necessary, as flake.nix is the default - - make-shells.default = { - inputsFrom = [ config.flake-root.devShell ]; # Adds $FLAKE_ROOT to environment - }; - }; -} diff --git a/nix/modules/go-forwarder.nix b/nix/modules/go-forwarder.nix deleted file mode 100644 index 1ef6857c..00000000 --- a/nix/modules/go-forwarder.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - perSystem = - { - config, - pkgs, - lib, - ... - }: - { - make-shells.default = { - # Go 1.24 compiler – align with go.mod - packages = [ pkgs.go_1_24 ]; - shellHook = '' - GOPATH="''$(${lib.getExe config.flake-root.package})"/.go_cache - export GOPATH - ''; - }; - }; -} diff --git a/nix/modules/just-flake.nix b/nix/modules/just-flake.nix deleted file mode 100644 index e7a0d2db..00000000 --- a/nix/modules/just-flake.nix +++ /dev/null @@ -1,26 +0,0 @@ -# Provides pretty banner & command index for this flake - -{ inputs, ... }: -{ - imports = [ inputs.just-flake.flakeModule ]; - perSystem = - { config, ... }: - { - just-flake.features = { - # treefmt.enable = true; - # rust.enable = true; - # convco.enable = true; - # hello = { - # enable = true; - # justfile = '' - # hello: - # echo Hello World - # ''; - # }; - }; - - make-shells.default = { - inputsFrom = [ config.just-flake.outputs.devShell ]; - }; - }; -} diff --git a/nix/modules/macmon.nix b/nix/modules/macmon.nix deleted file mode 100644 index 23fa9457..00000000 --- a/nix/modules/macmon.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - perSystem = - { lib, pkgs, ... }: - lib.mkMerge [ - (lib.mkIf pkgs.stdenv.isDarwin { - make-shells.default = { - packages = [ pkgs.macmon ]; - }; - }) - ]; - -} diff --git a/nix/modules/pkgs-init.nix b/nix/modules/pkgs-init.nix deleted file mode 100644 index f75c5944..00000000 --- a/nix/modules/pkgs-init.nix +++ /dev/null @@ -1,62 +0,0 @@ -# Single module responsible for collecting all overlays and instantiating in one go - -{ - flake-parts-lib, - inputs, - self, - specialArgs, - ... -}: -let - inherit (flake-parts-lib) mkPerSystemOption; -in -{ - options.perSystem = mkPerSystemOption ( - { - system, - config, - lib, - options, - pkgs, - self', - ... - }@args: - let - inherit (lib.types) - attrsOf - listOf - submoduleWith - raw - ; - in - { - options.pkgs-init.overlays = lib.mkOption { - description = '' - List of nixpkgs overlays (functions of the form: final: prev: { ... }). - Any module can append. Order matters. - ''; - default = [ ]; - example = [ - (final: prev: { - my-hello = prev.hello; - }) - ]; - type = lib.types.listOf lib.types.unspecified; - }; - options.pkgs-init.importArgs = lib.mkOption { - description = "Extra arguments merged into the nixpkgs import call."; - default = { }; - type = lib.types.attrs; - }; - config = { - _module.args.pkgs = import inputs.nixpkgs ( - { - inherit system; - overlays = config.pkgs-init.overlays; - } - // config.pkgs-init.importArgs - ); - }; - } - ); -} diff --git a/nix/modules/python.nix b/nix/modules/python.nix deleted file mode 100644 index ccda8358..00000000 --- a/nix/modules/python.nix +++ /dev/null @@ -1,20 +0,0 @@ -# Configures Python shell - -{ - perSystem = - { pkgs, ... }: - { - make-shells.default = { - packages = [ - pkgs.python313 - pkgs.uv - pkgs.ruff - pkgs.basedpyright - ]; - - shellHook = '' - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.python313}/lib - ''; - }; - }; -} diff --git a/nix/modules/rust.nix b/nix/modules/rust.nix deleted file mode 100644 index 1eb4865d..00000000 --- a/nix/modules/rust.nix +++ /dev/null @@ -1,25 +0,0 @@ -# Configures Rust shell - -{ inputs, ... }: -{ - perSystem = - { pkgs, ... }: - { - pkgs-init.overlays = [ - inputs.fenix.overlays.default - ]; - - make-shells.default = { - packages = [ - (pkgs.fenix.complete.withComponents [ - "cargo" - "rustc" - "clippy" - "rustfmt" - "rust-src" - ]) - pkgs.rustup # literally only added to make RustRover happy (otherwise useless) - ]; - }; - }; -}