remove shell.nix, add flake.nix

This commit is contained in:
Vinzenz Schroeter 2025-05-02 12:55:18 +02:00
parent 816cc2c8c3
commit e97bfd22e9
4 changed files with 168 additions and 5 deletions

2
.envrc
View file

@ -1 +1 @@
use nix
use flake

64
flake.lock Normal file
View file

@ -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
}

103
flake.nix Normal file
View file

@ -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);
};
}

View file

@ -1,4 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs.buildPackages; [ rustup cargo pkg-config xe lzma ];
}