diff --git a/Cargo.lock b/Cargo.lock index 90bb6e3..4611982 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -152,13 +152,13 @@ dependencies = [ [[package]] name = "derive-new" -version = "0.5.9" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" +checksum = "2cdc8d50f426189eef89dac62fabfa0abb27d5cc008f25bf4156a0203325becc" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", ] [[package]] @@ -317,7 +317,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn", ] [[package]] @@ -455,7 +455,7 @@ checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn", ] [[package]] @@ -515,17 +515,6 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.63" @@ -575,7 +564,7 @@ checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn", ] [[package]] @@ -672,7 +661,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn", ] [[package]] diff --git a/default.nix b/default.nix index eca00ba..1d976a3 100644 --- a/default.nix +++ b/default.nix @@ -1,20 +1,11 @@ -{ - pkgs ? import { }, -}: -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 diff --git a/flake.lock b/flake.lock index 1728de9..fb31d0a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,34 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1730652660, + "narHash": "sha256-+XVYfmVXAiYA0FZT7ijHf555dxCe+AoAT5A6RU+6vSo=", + "owner": "ipetkov", + "repo": "crane", + "rev": "a4ca93905455c07cb7e3aca95d4faf7601cba458", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -20,38 +49,24 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720957393, - "narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "693bc46d169f5af9c992095736e82c3488bf7dbb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1718428119, - "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", + "lastModified": 1730741070, + "narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", + "rev": "d063c1dd113c91ab27959ba540c0d9753409edf3", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { + "crane": "crane", + "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" @@ -59,7 +74,9 @@ }, "rust-overlay": { "inputs": { - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1721096425, diff --git a/flake.nix b/flake.nix index f322b9a..0a53e69 100644 --- a/flake.nix +++ b/flake.nix @@ -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 + ''; + }; } ); } diff --git a/shell.nix b/shell.nix index fe1949c..0b89ca5 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ { - pkgs ? import { overlays = [ (import ) ]; }, + pkgs ? import { overlays = [ (import ) ]; }, }: pkgs.mkShell { buildInputs = with pkgs; [ diff --git a/winapps/Cargo.toml b/winapps/Cargo.toml index 4bbd936..de6be3e 100644 --- a/winapps/Cargo.toml +++ b/winapps/Cargo.toml @@ -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"