chore: cleanup + update nix flake

This commit is contained in:
seth 2024-01-27 23:49:35 -05:00
parent f4fa737124
commit 24c8406590
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
6 changed files with 91 additions and 109 deletions

95
flake.lock generated
View file

@ -8,11 +8,11 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1702362203,
"narHash": "sha256-etsSWZfvmVA9RWqixmoKTf+JLEMtjlOaLxh/tK80ZCg=",
"lastModified": 1706336364,
"narHash": "sha256-mJ5i2YIVKv6jTN2+l3oOUUej2NUVjJX/H3bAq6019ks=",
"owner": "nix-community",
"repo": "fenix",
"rev": "7622e4a2d4378861d9e83fc02c1eeb0e084bf3f2",
"rev": "eb683549b7d76b12d1a009f888b91b70ed34485f",
"type": "github"
},
"original": {
@ -24,11 +24,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
@ -37,31 +37,16 @@
"type": "github"
}
},
"flake-root": {
"locked": {
"lastModified": 1692742795,
"narHash": "sha256-f+Y0YhVCIJ06LemO+3Xx00lIcqQxSKJHXT/yk1RTKxw=",
"owner": "srid",
"repo": "flake-root",
"rev": "d9a70d9c7a5fd7f3258ccf48da9335e9b47c3937",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "flake-root",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
@ -78,11 +63,11 @@
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"lastModified": 1703887061,
"narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
"type": "github"
},
"original": {
@ -113,11 +98,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1702272962,
"narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=",
"lastModified": 1706173671,
"narHash": "sha256-lciR7kQUK2FCAYuszyd7zyRRmTaXVeoZsCyK6QFpGdk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d",
"rev": "4fddc9be4eaf195d631333908f2a454b03628ee5",
"type": "github"
},
"original": {
@ -129,16 +114,16 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"lastModified": 1704874635,
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
@ -150,11 +135,11 @@
]
},
"locked": {
"lastModified": 1701473968,
"narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=",
"lastModified": 1704982712,
"narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5",
"rev": "07f6395285469419cf9d078f59b5b49993198c00",
"type": "github"
},
"original": {
@ -174,11 +159,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1702325376,
"narHash": "sha256-biLGx2LzU2+/qPwq+kWwVBgXs3MVYT1gPa0fCwpLplU=",
"lastModified": 1705757126,
"narHash": "sha256-Eksr+n4Q8EYZKAN0Scef5JK4H6FcHc+TKNHb95CWm+c=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "e1d203c2fa7e2593c777e490213958ef81f71977",
"rev": "f56597d53fd174f796b5a7d3ee0b494f9e2285cc",
"type": "github"
},
"original": {
@ -187,40 +172,44 @@
"type": "github"
}
},
"proc-flake": {
"procfile-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1692742849,
"narHash": "sha256-Nv8SOX+O6twFfPnA9BfubbPLZpqc+UeK6JvIWnWkdb0=",
"owner": "srid",
"repo": "proc-flake",
"rev": "25291b6e3074ad5dd573c1cb7d96110a9591e10f",
"lastModified": 1706387387,
"narHash": "sha256-7C3HncC25yK1kvLp+/9KoBa1Iz5Ly2JtICqmCz2nvio=",
"owner": "getchoo",
"repo": "procfile-nix",
"rev": "31a33e4264e5c6214844993c5b508fb3500ef5cd",
"type": "github"
},
"original": {
"owner": "srid",
"repo": "proc-flake",
"owner": "getchoo",
"repo": "procfile-nix",
"type": "github"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-root": "flake-root",
"naersk": "naersk",
"nixpkgs": "nixpkgs",
"parts": "parts",
"pre-commit-hooks": "pre-commit-hooks",
"proc-flake": "proc-flake"
"procfile-nix": "procfile-nix"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1702322912,
"narHash": "sha256-CtQtHdJp6naa5xtMmrkNwZx0aVq4215RtWw5/f7l0zw=",
"lastModified": 1706295183,
"narHash": "sha256-VSyMaUsXfjb31B8/uT5cM5qXC1VOHLVsCi/bQuo3O/g=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "8c3e28e3e2d4f190b633fbd43d689b45b28b5598",
"rev": "596e5c77cf5b2b660b3ac2ce732fa0596c246d9b",
"type": "github"
},
"original": {

View file

@ -23,8 +23,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};
flake-root.url = "github:srid/flake-root";
proc-flake.url = "github:srid/proc-flake";
procfile-nix = {
url = "github:getchoo/procfile-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {parts, ...} @ inputs:
@ -35,8 +37,7 @@
./nix/deployment.nix
inputs.pre-commit-hooks.flakeModule
inputs.flake-root.flakeModule
inputs.proc-flake.flakeModule
inputs.procfile-nix.flakeModule
];
systems = [

View file

@ -14,7 +14,7 @@
...
}: let
crossPkgsFor =
rec {
{
x86_64-linux = {
x86_64 = pkgs.pkgsStatic;
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
@ -30,7 +30,7 @@
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic;
};
aarch64-darwin = x86_64-darwin;
aarch64-darwin = crossPkgsFor.x86_64-darwin;
}
.${system};
@ -56,17 +56,17 @@
optimizeSize = true;
};
newAttrs = lib.fix (finalAttrs: {
newAttrs = {
CARGO_BUILD_TARGET = target;
"CC_${target'}" = "${cc}/bin/${cc.targetPrefix}cc";
"CARGO_TARGET_${targetUpper}_RUSTFLAGS" = "-C target-feature=+crt-static";
"CARGO_TARGET_${targetUpper}_LINKER" = finalAttrs."CC_${target'}";
});
"CARGO_TARGET_${targetUpper}_LINKER" = newAttrs."CC_${target'}";
};
inherit (crossPkgsFor.${arch}.stdenv) cc;
in
lib.getExe (
refraction.overrideAttrs (_: newAttrs)
refraction.overrideAttrs (lib.const newAttrs)
);
containerFor = arch:

View file

@ -7,47 +7,35 @@
SystemConfiguration,
version,
optimizeSize ? false,
}: let
filter = path: type: let
path' = toString path;
base = baseNameOf path';
parent = baseNameOf (dirOf path');
}:
naersk.buildPackage {
pname = "refraction";
inherit version;
dirBlocklist = ["nix"];
matches = lib.any (suffix: lib.hasSuffix suffix base) [".rs"];
isCargo = base == "Cargo.lock" || base == "Cargo.toml";
isTag = parent == "tags";
isAllowedDir = !(builtins.elem base dirBlocklist);
in
(type == "directory" && isAllowedDir) || matches || isCargo || isTag;
filterSource = src:
lib.cleanSourceWith {
src = lib.cleanSource src;
inherit filter;
};
in
naersk.buildPackage {
pname = "refraction";
inherit version;
src = filterSource ../.;
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
CoreFoundation
Security
SystemConfiguration
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../src
../build.rs
../Cargo.lock
../Cargo.toml
../tags
];
};
RUSTFLAGS = lib.optionalString optimizeSize "-C codegen-units=1 -C strip=symbols -C opt-level=z";
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
CoreFoundation
Security
SystemConfiguration
];
meta = with lib; {
mainProgram = "refraction";
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = licenses.gpl3Plus;
platforms = with platforms; linux ++ darwin;
maintainers = with maintainers; [getchoo Scrumplex];
};
}
cargoBuildFlags = lib.optionals optimizeSize ["-C" "codegen-units=1" "-C" "strip=symbols" "-C" "opt-level=z"];
meta = with lib; {
mainProgram = "refraction";
description = "Discord bot for Prism Launcher";
homepage = "https://github.com/PrismLauncher/refraction";
license = licenses.gpl3Plus;
maintainers = with maintainers; [getchoo Scrumplex];
};
}

View file

@ -9,7 +9,9 @@
pre-commit.settings.hooks = {
actionlint.enable = true;
alejandra.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
statix.enable = true;
nil.enable = true;
prettier = {
enable = true;
@ -17,8 +19,8 @@
};
};
proc.groups.daemons.processes = {
redis.command = "${lib.getExe' pkgs.redis "redis-server"}";
procfiles.daemons.processes = {
redis = lib.getExe' pkgs.redis "redis-server";
};
devShells.default = pkgs.mkShell {
@ -29,7 +31,7 @@
packages = with pkgs; [
# general
actionlint
config.proc.groups.daemons.package
config.procfiles.daemons.package
# rust
cargo
@ -40,7 +42,9 @@
# nix
self'.formatter
deadnix
nil
statix
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

View file

@ -6,12 +6,12 @@
perSystem = {
pkgs,
system,
config,
self',
...
}: {
packages = {
refraction = pkgs.callPackage ./derivation.nix {
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
version = builtins.substring 0 7 self.rev or "dirty";
inherit
(pkgs.darwin.apple_sdk.frameworks)
@ -23,7 +23,7 @@
naersk = inputs.naersk.lib.${system};
};
default = config.packages.refraction;
default = self'.packages.refraction;
};
};
}