diff --git a/flake.lock b/flake.lock index 880d73fa..bf94eca6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,133 +1,43 @@ { "nodes": { - "crane": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1702141249, - "narHash": "sha256-8wDpJKbDTDqFmyJfNEJOLrHYDoEzCjCbmz+lSRoU3CI=", - "owner": "ipetkov", - "repo": "crane", - "rev": "62fc1a0cbe144c1014d956e603d56bf1ffe69c7d", - "type": "github" - }, - "original": { - "owner": "ipetkov", - "repo": "crane", - "type": "github" - } - }, - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1702275809, - "narHash": "sha256-cd+IhiNJ9VYSheVxPzw6aLy91Q3+BUR35CtBqPCXfRE=", - "owner": "nix-community", - "repo": "fenix", - "rev": "ab4ec60bcf513278aa1e26d71ca822161075bffc", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "fenix", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nix-filter": { - "locked": { - "lastModified": 1701697642, - "narHash": "sha256-L217WytWZHSY8GW9Gx1A64OnNctbuDbfslaTEofXXRw=", - "owner": "numtide", - "repo": "nix-filter", - "rev": "c843418ecfd0344ecb85844b082ff5675e02c443", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "nix-filter", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1702206697, - "narHash": "sha256-vE9oEx3Y8TO5MnWwFlmopjHd1JoEBno+EhsfUCq5iR8=", + "lastModified": 1772963539, + "narHash": "sha256-9jVDGZnvCckTGdYT53d/EfznygLskyLQXYwJLKMPsZs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "29d6c96900b9b576c2fb89491452f283aa979819", + "rev": "9dcb002ca1690658be4a04645215baea8b95f31d", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" } }, "root": { "inputs": { - "crane": "crane", - "fenix": "fenix", - "flake-utils": "flake-utils", - "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" } }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1702247072, - "narHash": "sha256-JX+pWFPjckWD0Qa2oji1ZUbzL4kCIgeGsVcEb0Bnn+E=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "457b966b171b09a7e57acb710fbca29a4b3526f0", - "type": "github" + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } - }, - "systems": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1773025773, + "narHash": "sha256-Wik8+xApNfldpUFjPmJkPdg0RrvUPSWGIZis+A/0N1w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3c06fdbbd36ff60386a1e590ee0cd52dcd1892bf", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "oxalica", + "repo": "rust-overlay", "type": "github" } } diff --git a/flake.nix b/flake.nix index 83a6b70a..e23d6c77 100644 --- a/flake.nix +++ b/flake.nix @@ -2,63 +2,149 @@ description = "Settings daemon for the COSMIC desktop environment"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - nix-filter.url = "github:numtide/nix-filter"; - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - fenix = { - url = "github:nix-community/fenix"; + nixpkgs.url = "nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { self, nixpkgs, flake-utils, nix-filter, crane, fenix }: - flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - craneLib = crane.lib.${system}.overrideToolchain fenix.packages.${system}.stable.toolchain; - - pkgDef = { - src = nix-filter.lib.filter { - root = ./.; - include = [ - ./src - ./Cargo.toml - ./Cargo.lock - ]; - }; - nativeBuildInputs = with pkgs; [ pkg-config ]; + outputs = + { + self, + nixpkgs, + rust-overlay, + }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + pkgsForSystem = + system: + import nixpkgs { + inherit system; + overlays = [ (import rust-overlay) ]; + }; + + commonFor = + system: + let + pkgs = pkgsForSystem system; + rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; buildInputs = with pkgs; [ - systemd # For libudev + rustToolchain + libxkbcommon + libinput + libpulseaudio.dev + pipewire.dev + systemd + openssl + udev + ]; + + nativeBuildInputs = with pkgs; [ + pkg-config ]; - }; - cargoArtifacts = craneLib.buildDepsOnly pkgDef; - cosmic-settings-daemon = craneLib.buildPackage (pkgDef // { - inherit cargoArtifacts; - }); - in { - checks = { - inherit cosmic-settings-daemon; + runtimeDependencies = with pkgs; [ + ]; + in + { + inherit + pkgs + rustToolchain + buildInputs + nativeBuildInputs + runtimeDependencies + ; }; + in + { + packages = forAllSystems ( + system: + let + c = commonFor system; + rustPlatform = c.pkgs.makeRustPlatform { + cargo = c.rustToolchain; + rustc = c.rustToolchain; + }; + in + { + default = self.packages.${system}.cosmic-settings-daemon; + cosmic-settings-daemon = rustPlatform.buildRustPackage { + pname = "cosmic-settings-daemon"; + version = "1.m.M-dev"; - packages.default = cosmic-settings-daemon; + src = c.pkgs.lib.fileset.toSource { + root = ./.; + fileset = c.pkgs.lib.fileset.unions [ + ./config + ./cosmic-settings-daemon-config + ./data + ./geonames + ./src + ./Cargo.toml + ./Cargo.lock + ./Makefile + ]; + }; - apps.default = flake-utils.lib.mkApp { - drv = cosmic-settings-daemon; - }; + cargoLock = { + lockFile = ./Cargo.lock; + allowBuiltinFetchGit = true; + }; - devShells.default = pkgs.mkShell { - inputsFrom = builtins.attrValues self.checks.${system}; - }; - }); + separateDebugInfo = true; - nixConfig = { - # Cache for the Rust toolchain in fenix - extra-substituters = [ "https://nix-community.cachix.org" ]; - extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; - }; + buildInputs = c.buildInputs; + nativeBuildInputs = c.nativeBuildInputs; + runtimeDependencies = c.runtimeDependencies; + + makeFlags = [ + "prefix=${placeholder "out"}" + "CARGO_TARGET_DIR=target/${c.pkgs.stdenv.hostPlatform.rust.cargoShortTarget}" + ]; + + dontCargoInstall = true; + + meta = with c.pkgs.lib; { + description = "Settings daemon for the COSMIC desktop environment"; + homepage = "https://github.com/pop-os/cosmic-settings-daemon"; + license = licenses.gpl3Only; + platforms = platforms.linux; + mainProgram = "cosmic-settings-daemon"; + }; + + }; + } + ); + + devShells = forAllSystems ( + system: + let + c = commonFor system; + in + { + default = c.pkgs.mkShell { + inputsFrom = [ self.packages.${system}.cosmic-settings-daemon ]; + + packages = with c.pkgs; [ + c.rustToolchain + rust-analyzer + ]; + + LD_LIBRARY_PATH = c.pkgs.lib.makeLibraryPath c.runtimeDependencies; + RUSTFLAGS = "-C link-arg=-Wl,-rpath,${c.pkgs.lib.makeLibraryPath c.runtimeDependencies}"; + + shellHook = '' + echo "COSMIC Settings Daemon development environment" + echo "Run 'cargo build' to build, 'cargo test' to test" + ''; + }; + } + ); + }; }