mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 16:57:56 +00:00
templates/rust-app: update
This commit is contained in:
parent
aa52173af2
commit
d704112695
@ -1,37 +0,0 @@
|
||||
{ lib
|
||||
, rustPlatform
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "app";
|
||||
version = "VERSION";
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
./Cargo.lock
|
||||
./Cargo.toml
|
||||
./LICENSE
|
||||
./meson.build
|
||||
./meson_options.txt
|
||||
./src
|
||||
];
|
||||
};
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Rust app";
|
||||
mainProgram = "app";
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
@ -1,42 +1,20 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
description = "Basic Rust app development flake";
|
||||
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs = { nixpkgs, ... }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
systems = [ "x86_64-linux" ];
|
||||
forAllSystems = f: lib.genAttrs systems (system: f system);
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = import ./shell.nix { inherit pkgs; };
|
||||
});
|
||||
in {
|
||||
devShells = forAllSystems (system:
|
||||
let pkgs = import nixpkgs { inherit system; };
|
||||
in { default = import ./nix/shell.nix { inherit pkgs; }; });
|
||||
|
||||
packages = forAllSystems
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = pkgs.callPackage ./. { };
|
||||
});
|
||||
packages = forAllSystems (system:
|
||||
let pkgs = import nixpkgs { inherit system; };
|
||||
in { default = pkgs.callPackage ./nix/package.nix { }; });
|
||||
};
|
||||
}
|
||||
|
3
templates/rust-app/nix/default.nix
Normal file
3
templates/rust-app/nix/default.nix
Normal file
@ -0,0 +1,3 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.callPackage ./package.nix { }
|
23
templates/rust-app/nix/package.nix
Normal file
23
templates/rust-app/nix/package.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{ lib, stdenv, rustPlatform, cargo, rustc, meson, ninja, pkg-config }:
|
||||
|
||||
let metadata = lib.importTOML ../Cargo.toml;
|
||||
in stdenv.mkDerivation (finalAttrs: {
|
||||
pname = metadata.package.name;
|
||||
version = metadata.package.version;
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset =
|
||||
lib.fileset.unions [ ../Cargo.lock ../Cargo.toml ../src ../meson.build ];
|
||||
};
|
||||
|
||||
nativeBuildInputs =
|
||||
[ meson ninja pkg-config rustPlatform.cargoSetupHook cargo rustc ];
|
||||
|
||||
meta = with lib; {
|
||||
description = metadata.package.description;
|
||||
mainProgram = metadata.package.name;
|
||||
platforms = platforms.unix;
|
||||
license = with licenses; [ ];
|
||||
};
|
||||
})
|
18
templates/rust-app/nix/shell.nix
Normal file
18
templates/rust-app/nix/shell.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
let app = pkgs.callPackage ./package.nix { };
|
||||
in pkgs.mkShell {
|
||||
inputsFrom = [ app ];
|
||||
|
||||
# The rest of the development-related packages should be here.
|
||||
packages = with pkgs; [
|
||||
direnv
|
||||
clippy
|
||||
rust-analyzer
|
||||
|
||||
# The formatters used in this project.
|
||||
treefmt # The universal formatter (if configured nicely).
|
||||
nixfmt # The universal Nix formatter.
|
||||
rustfmt # The universal Rust formatter.
|
||||
];
|
||||
}
|
Loading…
Reference in New Issue
Block a user