Skip to content

Commit

Permalink
nix: logically split packaging to not be flake-dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
itslychee committed Jun 6, 2024
1 parent 747be63 commit e2b7cf1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 50 deletions.
36 changes: 4 additions & 32 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,4 @@
{
rustPlatform,
gtk4,
glib,
polkit,
pkg-config,
}: let
polkitAgentPath = "${polkit}/lib/polkit-1/polkit-agent-helper-1";
pname = "soteria";
version = "0.1.0";
in
rustPlatform.buildRustPackage rec {
inherit pname version;
POLKIT_AGENT_HELPER_PATH = polkitAgentPath;

nativeBuildInputs = [
pkg-config
];

buildInputs = [
gtk4
glib
polkit
];
inherit glib;

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};
}
{pkgs ? import <nixpkgs> {}}: rec {
soteria = pkgs.callPackage ./package.nix {};
default = soteria;
}
35 changes: 17 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@
nixpkgs,
}: let
supportedSystems = ["x86_64-linux"];
eachSystem = nixpkgs.lib.genAttrs supportedSystems;
eachSystem = f:
nixpkgs.lib.genAttrs supportedSystems
(system: f nixpkgs.legacyPackages.${system});
in {
packages = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
soteria = pkgs.callPackage ./default.nix {};
default = self.packages.${system}.soteria;
packages = eachSystem (pkgs: import ./. {inherit pkgs;});
devShells = eachSystem (pkgs: {
default = pkgs.mkShell (let
soteria = self.packages.${pkgs.system}.default;
in {
inherit (soteria) POLKIT_AGENT_HELPER_PATH;
inputsFrom = [
soteria
];
packages = builtins.attrValues {
inherit (pkgs) rust-analyzer rustfmt;
};
});
});

devShell = eachSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in pkgs.mkShell {
packages = with pkgs; [
gtk4
glib
polkit
pkg-config
cargo
];
});

formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra);
formatter = eachSystem (pkgs: pkgs.alejandra);
};
}
30 changes: 30 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
rustPlatform,
gtk4,
glib,
polkit,
pkg-config,
}: let
pname = "soteria";
version = "0.1.0";
in
rustPlatform.buildRustPackage rec {
inherit pname version;
POLKIT_AGENT_HELPER_PATH = "${polkit.out}/lib/polkit-1/polkit-agent-helper-1";

nativeBuildInputs = [
pkg-config
];

buildInputs = [
gtk4
glib
polkit
];

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};
}

0 comments on commit e2b7cf1

Please sign in to comment.