From e97bfd22e99fb73dd587574c936989878a66e261 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Fri, 2 May 2025 12:55:18 +0200 Subject: [PATCH] remove shell.nix, add flake.nix --- .envrc | 2 +- flake.lock | 64 +++++++++++++++++++++++++++++++++ flake.nix | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++ shell.nix | 4 --- 4 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.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..8c4b6bb --- /dev/null +++ b/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "naersk": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745925850, + "narHash": "sha256-cyAAMal0aPrlb1NgzMxZqeN1mAJ2pJseDhm2m6Um8T0=", + "owner": "nix-community", + "repo": "naersk", + "rev": "38bc60bbc157ae266d4a0c96671c6c742ee17a5f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1731533336, + "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "f7653272fd234696ae94229839a99b73c9ab7de0", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1746055187, + "narHash": "sha256-3dqArYSMP9hM7Qpy5YWhnSjiqniSaT2uc5h2Po7tmg0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3e362ce63e16b9572d8c2297c04f7c19ab6725a5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "naersk": "naersk", + "nix-filter": "nix-filter", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..043b61f --- /dev/null +++ b/flake.nix @@ -0,0 +1,103 @@ +{ + description = "Flake for command line interface of the ServicePoint display."; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + nix-filter.url = "github:numtide/nix-filter"; + naersk = { + url = "github:nix-community/naersk"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs@{ + self, + nixpkgs, + naersk, + nix-filter, + }: + let + lib = nixpkgs.lib; + supported-systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + forAllSystems = + f: + lib.genAttrs supported-systems ( + system: + f rec { + pkgs = nixpkgs.legacyPackages.${system}; + naersk' = pkgs.callPackage naersk { }; + selfPkgs = self.packages."${system}"; + inherit system; + } + ); + in + rec { + packages = forAllSystems ( + { pkgs, naersk', ... }: + rec { + servicepoint-life = naersk'.buildPackage rec { + strictDeps = true; + nativeBuildInputs = with pkgs; [ pkg-config ]; + buildInputs = with pkgs; [ + xe + xz + ]; + src = nix-filter.lib.filter { + root = ./.; + include = [ + ./Cargo.toml + ./Cargo.lock + ./src + ./README.md + ./LICENSE + ]; + }; + }; + + default = servicepoint-life; + } + ); + + legacyPackages = packages; + + apps = forAllSystems ( + { selfPkgs, ... }: + rec { + servicepoint-life = { + type = "app"; + program = "${selfPkgs.servicepoint-life}/out/servicepoint-life"; + }; + default = servicepoint-life; + } + ); + + devShells = forAllSystems ( + { pkgs, selfPkgs, ... }: + { + default = pkgs.mkShell rec { + inputsFrom = [ selfPkgs.default ]; + packages = [ + pkgs.gdb + (pkgs.symlinkJoin { + name = "rust-toolchain"; + paths = with pkgs; [ + rustc + cargo + rustfmt + clippy + ]; + }) + ]; + }; + } + ); + + formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 0bf2bcc..0000000 --- a/shell.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs ? import {} }: - pkgs.mkShell { - nativeBuildInputs = with pkgs.buildPackages; [ rustup cargo pkg-config xe lzma ]; -}