From 373b82328537f102ae9e393ca34baed392029c7e Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Thu, 7 Nov 2024 20:18:49 +0100 Subject: [PATCH] wip nix flake --- .envrc | 2 +- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ shell.nix | 30 ++++++++++++++++++++++++++++-- 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc index 1d953f4..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..265bb04 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1730883749, + "narHash": "sha256-mwrFF0vElHJP8X3pFCByJR365Q2463ATp2qGIrDUdlE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "dba414932936fde69f0606b4f1d87c5bc0003ede", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..230c912 --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "Flake for servicepoint-simulator"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; + }; + + outputs = + inputs@{ self, nixpkgs }: + rec { + packages.hello = nixpkgs.rustPlatform.buildRustPackage rec { + pname = "servicepoint-simulator"; + version = "0.0.1"; + + src = [ ]; # TODO: src, Cargo.toml etc + + buildInputs = [ + + ]; + nativeBuildInputs = with nixpkgs.legacyPackages.x86_64-linux; [ pkgconfig ]; + cargoSha256 = "sha256-0hfmV4mbr3l86m0X7EMYTOu/b+BjueVEbbyQz0KgOFY="; + + meta = with nixpkgs.stdenv.lib; { + homepage = ""; + description = ""; + #license = licenses.gplv3; + }; + + legacyPackages = packages; + + defaultPackage = packages.hello; + }; + + devShells.x86_64-linux.default = import ./shell.nix { pkgs = nixpkgs.legacyPackages.x86_64-linux; }; + + formatter = { + x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; + aarch64-linux = nixpkgs.legacyPackages.aarch64-linux.nixfmt-rfc-style; + }; + }; +} diff --git a/shell.nix b/shell.nix index 37dc58d..ceff669 100644 --- a/shell.nix +++ b/shell.nix @@ -1,14 +1,40 @@ -{pkgs ? import {}}: +{ + pkgs ? import { }, +}: +let + rust-toolchain = pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [ + rustc + cargo + rustPlatform.rustcSrc + rustfmt + clippy + cargo-expand + ]; + }; +in pkgs.mkShell { nativeBuildInputs = with pkgs.buildPackages; [ - rustc cargo gcc rustfmt clippy + rust-toolchain pkg-config xe lzma + + # linux x11 / wayland libxkbcommon + #xorg.libxkbfile wayland ]; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ( + with pkgs; + [ + wayland + libxkbcommon + ] + ); }