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

View file

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

View file

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

View file

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

View file

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

View file

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