From e44c8501c9aacde25a9469331fd975bba738a532 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 3 Jul 2023 13:54:33 +0200 Subject: [PATCH] Flake cleanup --- default.nix | 7 ---- flake.nix | 79 +++++++++++++++++++++++++++------------------ rust-toolchain.toml | 3 ++ shell.nix | 7 ---- 4 files changed, 51 insertions(+), 45 deletions(-) delete mode 100644 default.nix create mode 100644 rust-toolchain.toml delete mode 100644 shell.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 39bacff..0000000 --- a/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -(import ( - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).defaultNix diff --git a/flake.nix b/flake.nix index 3e70b8f..0776a44 100644 --- a/flake.nix +++ b/flake.nix @@ -1,43 +1,60 @@ { - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - utils.url = "github:numtide/flake-utils"; + flake-utils.url = "github:numtide/flake-utils"; naersk = { url = "github:nmattia/naersk/master"; inputs.nixpkgs.follows = "nixpkgs"; }; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; }; - outputs = { self, nixpkgs, utils, naersk }: - utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - naersk-lib = pkgs.callPackage naersk { }; - in - rec { + outputs = { + self, + nixpkgs, + flake-utils, + naersk, + rust-overlay, + }: + flake-utils.lib.eachDefaultSystem (system: let + overlays = [(import rust-overlay)]; + pkgs = import nixpkgs {inherit system overlays;}; + naersk-lib = pkgs.callPackage naersk {}; - defaultPackage = naersk-lib.buildPackage { - root = ./.; - pname = "pamedia"; - buildInputs = with pkgs; [ libpulseaudio ]; - nativeBuildInputs = with pkgs; [ pkg-config ]; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + + buildInputs = [ + rustToolchain + pkgs.libpulseaudio.dev + ]; + nativeBuildInputs = [ + pkgs.pkgconf + ]; + in rec { + packages.pamedia = naersk-lib.buildPackage { + inherit buildInputs nativeBuildInputs; + + root = ./.; + pname = "pamedia"; + }; + packages.default = packages.pamedia; + + defaultApp = flake-utils.lib.mkApp { + drv = self.defaultPackage."${system}"; + }; + + overlays = final: prev: { + pamedia = packages.pamedia; + }; + + devShell = with pkgs; + mkShell { + buildInputs = [cargo rustc rustfmt pre-commit rustPackages.clippy cargo-edit cargo-feature cargo-outdated rust-analyzer] ++ buildInputs; + nativeBuildInputs = [libnotify] ++ nativeBuildInputs; }; - - defaultApp = utils.lib.mkApp { - drv = self.defaultPackage."${system}"; - }; - - overlays = final: prev: { - pamedia = defaultPackage; - }; - - devShell = with pkgs; mkShell { - buildInputs = [ cargo rustc rustfmt pre-commit rustPackages.clippy cargo-edit cargo-feature cargo-outdated ] ++ defaultPackage.buildInputs; - nativeBuildInputs = [ ] ++ defaultPackage.nativeBuildInputs; - RUST_SRC_PATH = rustPlatform.rustLibSrc; - }; - - }); - + }); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..cf9cf4d --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +components = [ "rustfmt", "clippy" ] \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 77db547..0000000 --- a/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -(import ( - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; - sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } -) { - src = ./.; -}).shellNix