diff options
| -rw-r--r-- | flake.lock | 55 | ||||
| -rw-r--r-- | flake.nix | 65 | ||||
| -rw-r--r-- | nix/package.nix | 17 | ||||
| -rw-r--r-- | src/main.rs | 1 |
4 files changed, 63 insertions, 75 deletions
@@ -1,5 +1,20 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1765739568, + "narHash": "sha256-gQYx35Of4UDKUjAYvmxjUEh/DdszYeTtT6MDin4loGE=", + "owner": "ipetkov", + "repo": "crane", + "rev": "67d2baff0f9f677af35db61b32b5df6863bcc075", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -19,66 +34,42 @@ "type": "github" } }, - "naersk": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1698420672, - "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", - "owner": "nmattia", - "repo": "naersk", - "rev": "aeb58d5e8faead8980a807c840232697982d47b9", - "type": "github" - }, - "original": { - "owner": "nmattia", - "ref": "master", - "repo": "naersk", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1701539137, - "narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=", + "lastModified": 1765838191, + "narHash": "sha256-m5KWt1nOm76ILk/JSCxBM4MfK3rYY7Wq9/TZIIeGnT8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d", + "rev": "c6f52ebd45e5925c188d1a20119978aa4ffd5ef6", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixos-25.11", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { + "crane": "crane", "flake-utils": "flake-utils", - "naersk": "naersk", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } }, "rust-overlay": { "inputs": { - "flake-utils": [ - "flake-utils" - ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1715134005, - "narHash": "sha256-oujsCgNiQnZoQntNkkNkA7BhCmUvf9FLWj+2oGT2Jvc=", + "lastModified": 1765939271, + "narHash": "sha256-7F/d+ZrTYyOxnBZcleQZjOOEWc1IMXR/CLLRLLsVtHo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a8bfc2569a1965c0da8711d289d973f0011b441a", + "rev": "8028944c1339469124639da276d403d8ab7929a8", "type": "github" }, "original": { @@ -1,21 +1,14 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; flake-utils.url = "github:numtide/flake-utils/main"; rust-overlay = { url = "github:oxalica/rust-overlay/master"; - - inputs = { - flake-utils.follows = "flake-utils"; - nixpkgs.follows = "nixpkgs"; - }; - }; - - naersk = { - url = "github:nmattia/naersk/master"; inputs.nixpkgs.follows = "nixpkgs"; }; + + crane.url = "github:ipetkov/crane"; }; description = "thulani discord bot"; @@ -26,7 +19,23 @@ flake-utils, ... } @ inputs: let - mkBuildToolchain = pkgs: pkgs.rust-bin.nightly."2024-05-01".minimal; + inherit (nixpkgs) lib; + mkBuildToolchain = pkgs: pkgs.rust-bin.nightly."2025-12-01".minimal; + + rustsrc = let + filter = with lib.fileset; unions [ + (maybeMissing ./.cargo/config.toml) + ./README.md + ./Cargo.lock + (fileFilter (file: file.hasExt "rs") ./.) + (fileFilter (file: file.hasExt "sql") ./.) + (fileFilter (file: file.hasExt "pest") ./.) + (fileFilter (file: file.name == "Cargo.toml") ./.) + ]; + in lib.fileset.toSource { + root = ./.; + fileset = filter; + }; deps = pkgs: with pkgs; [ openssl @@ -37,42 +46,14 @@ mkPkg = pkgs: let buildToolchain = mkBuildToolchain pkgs; - - naersk = pkgs.callPackage inputs.naersk { - cargo = buildToolchain; - rustc = buildToolchain; - }; + crane = (inputs.crane.mkLib pkgs).overrideToolchain mkBuildToolchain; inherit (pkgs) lib; - in naersk.buildPackage { - pname = "thulani"; - version = self.rev or "dirty"; - - src = lib.cleanSourceWith { - src = lib.cleanSource ./.; - - filter = path: ty: with builtins; with lib; let - baseName = baseNameOf "${path}"; - extMatch = match "((.*\\.?)*\\.)?(.*)" baseName; - extension = elemAt extMatch 2; - parent = baseNameOf (dirOf "${path}"); - isCargoFile = baseName == "Cargo.toml" || baseName == "Cargo.lock"; - isCargoConfig = parent == ".cargo" && baseName == "config.toml"; - in - ty == "directory" || - isCargoFile || - isCargoConfig || - extension == "rs" || - extension == "sql" || - extension == "pest"; - }; - - nativeBuildInputs = deps pkgs; - remapPathPrefix = true; + in pkgs.callPackage ./nix/package.nix { + inherit crane rustsrc; }; - in (flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..1175efa --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,17 @@ +{ + openssl, + pkg-config, + libopus, + postgresql, + + crane, + rustsrc, +}: crane.buildPackage { + src = rustsrc; + nativeBuildInputs = [ + openssl + pkg-config + libopus + postgresql + ]; +} diff --git a/src/main.rs b/src/main.rs index db22047..88f5913 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ #![feature(try_trait_v2)] #![feature(pattern)] -#![feature(concat_idents)] #![feature(associated_type_defaults)] #![feature(box_patterns)] #![allow(deprecated)] |
