From 765b6551688d59284f1df20d4ae671f6ad6a9372 Mon Sep 17 00:00:00 2001 From: AusCyberman Date: Mon, 12 Jul 2021 00:03:03 +1000 Subject: [PATCH] Added nix flake and nix shell (#205) * added flake * updated flake.lock * fixup! updated flake.lock * Added app packages * added default.nix for non flake systems * added compat for shell with non flake systems * changed to use fenix src * fixup! changed to use fenix src * get rid of the newlines, i guess? * fixup! get rid of the newlines, i guess? --- default.nix | 9 ++++ flake.lock | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 46 ++++++++++++++++ shell.nix | 30 +++++++++++ 4 files changed, 237 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..f8a169d --- /dev/null +++ b/default.nix @@ -0,0 +1,9 @@ +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in fetchTarball { + url = "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 new file mode 100644 index 00000000..03f19b8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,152 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "naersk": "naersk", + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1625970402, + "narHash": "sha256-UujmLdJfeIsCQQ9KfqvpzGRdAkINv3PGW/QKHuoMbc4=", + "owner": "nix-community", + "repo": "fenix", + "rev": "3ef613bb3b6431fa379574c96a23b9fc8d0d1c5f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1606424373, + "narHash": "sha256-oq8d4//CJOrVj+EcOaSXvMebvuTkmBJuT5tzlfewUnQ=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "99f1c2157fba4bfe6211a321fd0ee43199025dbf", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1623927034, + "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", + "owner": "nmattia", + "repo": "naersk", + "rev": "e09c320446c5c2516d430803f7b19f5833781337", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "naersk_2": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1623927034, + "narHash": "sha256-sGxlmfp5eXL5sAMNqHSb04Zq6gPl+JeltIZ226OYN0w=", + "owner": "nmattia", + "repo": "naersk", + "rev": "e09c320446c5c2516d430803f7b19f5833781337", + "type": "github" + }, + "original": { + "owner": "nmattia", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1625968520, + "narHash": "sha256-j/OZEG9JxRMJTdr033LXIFHLSMQBQYNTHicIsCPqL2c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f085e22dc2856873074ee5d0921d185a643279ff", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1625942347, + "narHash": "sha256-gNxZar+Mc8lv8FbBldl8ztKtUZU3/SJuL5eqCjW/m7U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fb45fa64ae3460d6bd2701ab5a6c4512d781f166", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "naersk": "naersk_2", + "nixpkgs": "nixpkgs_2" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1625937916, + "narHash": "sha256-Im6z7pzWV4gcmfHXxTdwSTJvVj8/pJ0qSDvyBwJFILE=", + "owner": "rust-analyzer", + "repo": "rust-analyzer", + "rev": "2e52d6ea938129e67b567e1310cf43976c036786", + "type": "github" + }, + "original": { + "owner": "rust-analyzer", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..4dbf99b --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + inputs = { + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + naersk.url = "github:nmattia/naersk"; + }; + outputs = { self, flake-utils, fenix, nixpkgs, naersk, flake-compat, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + # Add rust nightly to pkgs + pkgs = nixpkgs.legacyPackages.${system} // { inherit (fenix.packages.${system}.latest) cargo rustc rust-src; }; + + naersk-lib = (naersk.lib."${system}".override { + cargo = pkgs.cargo; + rustc = pkgs.rustc; + }); + + eww = naersk-lib.buildPackage { + pname = "eww"; + nativeBuildInputs = with pkgs; [ pkg-config gtk3 ]; + root = ./.; + }; + + + in + rec { + packages.eww = eww; + + defaultPackage = eww; + + apps.eww = flake-utils.lib.mkApp { + drv = eww; + }; + defaultApp = apps.eww; + + devShell = import ./shell.nix { inherit pkgs; }; + }); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..c352bd2 --- /dev/null +++ b/shell.nix @@ -0,0 +1,30 @@ +{ pkgs ? import { + overlays = [ + (import (fetchTarball + "https://github.com/nix-community/fenix/archive/main.tar.gz")) + (self: super: { + rustc = super.fenix.latest.rustc; + cargo = super.fenix.latest.cargo; + rust-src = super.fenix.latest.rust-src; + } + ) + ]; + } +}: + +pkgs.mkShell { + packages = with pkgs; [ + rustc + cargo + rust-analyzer + gcc + gtk3 + pkg-config + rustfmt + clippy + deno + ]; + + + RUST_SRC_PATH = "${pkgs.rust-src}/lib/rustlib/src/rust/library"; +}