From fb3e99f8e45c2c68fac690c7433f36d9048b72c8 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 17 Apr 2025 12:49:52 -0600 Subject: [PATCH] better flake? --- .gitignore | 6 ++++ flake.lock | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 75 +++++++++++++++--------------------------- 3 files changed, 128 insertions(+), 49 deletions(-) create mode 100644 flake.lock diff --git a/.gitignore b/.gitignore index 34537f4..94eb0df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,14 @@ +# Rust/Carge /target + +# Nix +result + # Main nix files flake.nix configuration.nix home.nix + # Extra nix files garrus.nix gnome.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1d51da6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1743800763, + "narHash": "sha256-YFKV+fxEpMgP5VsUcM6Il28lI0NlpM7+oB1XxbBAYCw=", + "owner": "nix-community", + "repo": "naersk", + "rev": "ed0232117731a4c19d3ee93aa0c382a8fe754b01", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + } + }, + "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", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 60a3ffd..c4579d1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,58 +1,35 @@ { - description = "Nyxi Installer flake"; + description = "Flake to build and develop Nyxi"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11"; + flake-utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nix-community/naersk"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; - outputs = { nixpkgs, ... } @ inputs: - - let - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - }; - in - { - checks.x86_64-linux.unitTests = (with pkgs; stdenv.mkDerivation { - pname = "nyxi-installer"; - version = "2.0.0"; - src = builtins.fetchGit { - url = "https://gitlab.com/ahoneybun/nyxi-installer.git"; - ref = "rust-rewrite"; - rev = "a0c8dafe6186de0c6eebc68d413d08bccd4e2405"; - }; + outputs = { self, flake-utils, naersk, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; - buildInputs = with pkgs; [ cargo rustc ]; + naersk' = pkgs.callPackage naersk {}; - buildPhase = '' - cargo test - ''; + in rec { + # For `nix build` & `nix run`: + defaultPackage = naersk'.buildPackage { + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + buildInputs = with pkgs; [ pkg-config openssl ]; + nativeBuildInputs = with pkgs; [ util-linux.dev ]; + src = ./.; + }; - }); - - devShells.x86_64-linux.default = pkgs.mkShell { - buildInputs = with pkgs; [ - cargo - rustc - gnumake - clang - llvmPackages.libclang - llvmPackages.clang - - # System - btrfs-progs - e2fsprogs - openssl - pkg-config - util-linux - ]; - shellHook = '' - export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" - export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" - export RUST_BACKTRACE=1 - echo "Ready to make some Rust!" - ''; - }; - }; + # For `nix develop` (optional, can be skipped): + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ rustc cargo ]; + }; + } + ); }