From 717c454a7e31c4ffc8baf6c1d1c90fd74a223e55 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 26 Jun 2023 18:20:34 -0400 Subject: [PATCH] feat: nix flake --- .gitignore | 2 + flake.lock | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 88 ++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5d0e7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +target diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4666ccf --- /dev/null +++ b/flake.lock @@ -0,0 +1,214 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1687310026, + "narHash": "sha256-20RHFbrnC+hsG4Hyeg/58LvQAK7JWfFItTPFAFamu8E=", + "owner": "ipetkov", + "repo": "crane", + "rev": "116b32c30b5ff28e49f4fcbeeb1bbe3544593204", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1687760804, + "narHash": "sha256-4aJlNuAI+AjrUid9hmjdqwJxT7y/HCHptC2dtDmuEWU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "2102665784dba3f11314e37b4027794ccd324f1d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1687178632, + "narHash": "sha256-HS7YR5erss0JCaUijPeyg2XrisEb959FIct3n2TMGbE=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "d90c75e8319d0dd9be67d933d8eb9d0894ec9174", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687701825, + "narHash": "sha256-aMC9hqsf+4tJL7aJWSdEUurW2TsjxtDcJBwM9Y4FIYM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "07059ee2fa34f1598758839b9af87eae7f7ae6ea", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "fenix": "fenix", + "flake-utils": "flake-utils_2", + "nix-filter": "nix-filter", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1687732103, + "narHash": "sha256-5Jn/Nj/xgcjTT289Itng55GLUBTEIULPndl/XrGkUwQ=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "4a2ceeff0fb53de168691b0f55d9808d221b867e", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1685759304, + "narHash": "sha256-I3YBH6MS3G5kGzNuc1G0f9uYfTcNY9NYoRc3QsykLk4=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c535b4f3327910c96dcf21851bbdd074d0760290", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fec42ee --- /dev/null +++ b/flake.nix @@ -0,0 +1,88 @@ +{ + description = "Launcher 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"; + 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 = ./.; + exclude = [ + ./.gitignore + ./flake.nix + ./flake.lock + ./LICENSE + ./debian + ]; + }; + nativeBuildInputs = with pkgs; [ + cmake + pkg-config + autoPatchelfHook + ]; + buildInputs = with pkgs; [ + libxkbcommon + libxkbcommon + freetype + fontconfig + expat + lld + desktop-file-utils + stdenv.cc.cc.lib + desktop-file-utils + ]; + runtimeDependencies = with pkgs; [ + wayland + ]; + }; + + cargoArtifacts = craneLib.buildDepsOnly pkgDef; + cosmic-workspaces= craneLib.buildPackage (pkgDef // { + inherit cargoArtifacts; + }); + in { + checks = { + inherit cosmic-workspaces; + }; + + packages.default = cosmic-workspaces.overrideAttrs (oldAttrs: rec { + buildPhase = '' + make prefix=$out + ''; + installPhase = '' + make prefix=$out install + ''; + }); + + apps.default = flake-utils.lib.mkApp { + drv = cosmic-workspaces; + }; + + devShells.default = pkgs.mkShell rec { + inputsFrom = builtins.attrValues self.checks.${system}; + LD_LIBRARY_PATH = pkgs.lib.strings.makeLibraryPath (builtins.concatMap (d: d.runtimeDependencies) inputsFrom); + }; + }); + + 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=" ]; + }; +}