Skip to content

Commit

Permalink
try new packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardotglobal committed Nov 8, 2024
1 parent f745e36 commit 21b7512
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 79 deletions.
27 changes: 8 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 11 additions & 20 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{
pkgs ? import <nixpkgs> { },
}:
let
manifest = (pkgs.lib.importTOML ./winapps-cli/Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage {
pname = manifest.name;
version = manifest.version;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;

cargoBuildFlags = "-p winapps-cli";

nativeBuildInputs = [ pkgs.pkg-config ];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";

propagatedBuildInputs = with pkgs; [ freerdp3 ];
wrapperArgs = [ ];
}
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url =
lock.nodes.flake-compat.locked.url
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix
59 changes: 38 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 50 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,63 @@
description = "WinApps package and dev shell";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";

rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};

crane.url = "github:ipetkov/crane";

rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
};

outputs =
{
nixpkgs,
rust-overlay,
flake-utils,
...
}:
outputs = {
nixpkgs,
rust-overlay,
crane,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
in
{
system: let
inherit (pkgs) lib;

pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};

craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal));
src = craneLib.cleanCargoSource ./.;

buildWorkspacePackage = {pname, ...} @ extraAttrs:
craneLib.buildPackage (
extraAttrs
// {
inherit src;
inherit (craneLib.crateNameFromCargoToml {cargoToml = ./${pname}/Cargo.toml;}) version;
cargoExtraArgs = "-p ${pname}";
}
);
in {
formatter = pkgs.nixfmt-rfc-style;
devShells.default = import ./shell.nix { inherit pkgs; };
devShells.default = import ./shell.nix {inherit pkgs;};

packages.winapps = buildWorkspacePackage {
pname = "winapps-cli";

nativeBuildInputs = [pkgs.makeWrapper];

postInstall = ''
wrapProgram $out/bin/winapps-cli \
--prefix PATH : ${lib.makeBinPath [pkgs.freerdp3]}
packages.winapps = pkgs.callPackage ./. { };
ln -s $out/bin/winapps-cli $out/bin/winapps
'';
};
}
);
}
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
pkgs ? import <nixpkgs-unstable> { overlays = [ (import <rust-overlay>) ]; },
pkgs ? import <nixpkgs> { overlays = [ (import <rust-overlay>) ]; },
}:
pkgs.mkShell {
buildInputs = with pkgs; [
Expand Down
2 changes: 1 addition & 1 deletion winapps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
anyhow = "1.0"
derive-new = "0.5"
derive-new = "0.7.0"
serde = { version = "1.0", features = ["derive"] }
toml = "0.8"
tracing = "0.1"
Expand Down

0 comments on commit 21b7512

Please sign in to comment.