1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-06-03 17:14:08 +02:00

flake reorg

This commit is contained in:
Robin Appelman 2024-02-16 11:35:00 +01:00
commit adf09c05cb
4 changed files with 54 additions and 11 deletions

View file

@ -32,7 +32,10 @@
in in
flake-utils.lib.eachDefaultSystem ( flake-utils.lib.eachDefaultSystem (
system: let system: let
overlays = [(import rust-overlay)]; overlays = [
(import rust-overlay)
(import ./overlay.nix)
];
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
config.allowUnfree = true; config.allowUnfree = true;
@ -44,11 +47,8 @@
hostTarget = pkgs.hostPlatform.config; hostTarget = pkgs.hostPlatform.config;
cross-naersk' = callPackage cross-naersk {inherit naersk;}; cross-naersk' = callPackage cross-naersk {inherit naersk;};
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
nearskOpt = { nearskOpt = {
pname = "haze"; inherit (pkgs.haze) src pname;
root = src;
}; };
buildTarget = target: (cross-naersk'.buildPackage target) nearskOpt; buildTarget = target: (cross-naersk'.buildPackage target) nearskOpt;
hostNaersk = cross-naersk'.hostNaersk; hostNaersk = cross-naersk'.hostNaersk;
@ -57,7 +57,7 @@
packages = packages =
genAttrs targets buildTarget genAttrs targets buildTarget
// rec { // rec {
haze = packages.${hostTarget}; inherit (pkgs) haze;
check = hostNaersk.buildPackage (nearskOpt check = hostNaersk.buildPackage (nearskOpt
// { // {
mode = "check"; mode = "check";
@ -81,7 +81,19 @@
} }
) )
// { // {
overlays.default = import ./overlay.nix;
homeManagerModules.default = {
pkgs,
config,
lib,
...
}: {
imports = [./hm-module.nix];
config = lib.mkIf config.programs.haze.enable {
nixpkgs.overlays = [self.overlays.default];
programs.haze.package = lib.mkDefault pkgs.haze;
};
};
inherit targets releaseTargets; inherit targets releaseTargets;
homeManagerModule = import ./hm-module.nix self.packages;
}; };
} }

View file

@ -1,4 +1,4 @@
packages: { {
config, config,
lib, lib,
pkgs, pkgs,
@ -43,7 +43,6 @@ with lib; let
}; };
} }
)); ));
pkg = packages.${pkgs.system}.default;
in { in {
options.programs.haze = { options.programs.haze = {
enable = mkEnableOption "haze"; enable = mkEnableOption "haze";
@ -165,11 +164,17 @@ in {
}; };
}); });
}; };
package = mkOption {
type = types.package;
defaultText = literalExpression "pkgs.haze";
description = "package to use";
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
xdg.configFile."haze/haze.toml".source = configFile; xdg.configFile."haze/haze.toml".source = configFile;
home.packages = [pkg]; home.packages = [cfg.package];
systemd.user.services.haze = { systemd.user.services.haze = {
Unit = { Unit = {
@ -177,7 +182,7 @@ in {
}; };
Service = { Service = {
ExecStart = "${pkg}/bin/haze proxy"; ExecStart = "${cfg.package}/bin/haze proxy";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 10; RestartSec = 10;
}; };

3
overlay.nix Normal file
View file

@ -0,0 +1,3 @@
final: prev: {
haze = final.callPackage ./package.nix {};
}

23
package.nix Normal file
View file

@ -0,0 +1,23 @@
{
stdenv,
rustPlatform,
libsodium,
pkg-config,
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
pname = "haze";
version = "0.1.0";
inherit src;
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"hyper-reverse-proxy-0.5.2-dev" = "sha256-8yBpYQZJaNhaecjR2GhQytRM4jgS0GaKzAxRXFmIf8k=";
};
};
}