From ffd906d9feb6032d905aa653e294760f6266b51e Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Thu, 17 Oct 2024 18:46:38 +0200 Subject: [PATCH] Add Nix Flake --- .envrc | 1 + .gitignore | 3 +++ flake.lock | 25 +++++++++++++++++++++++++ flake.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4425c7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.direnv/ +target +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..91a254e --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1728018373, + "narHash": "sha256-NOiTvBbRLIOe5F6RbHaAh6++BNjsb149fGZd1T4+KBg=", + "rev": "bc947f541ae55e999ffdb4013441347d83b00feb", + "revCount": 688563, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.688563%2Brev-bc947f541ae55e999ffdb4013441347d83b00feb/01925b66-3b70-71bd-b277-924a6c208ba7/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3d2c6eb --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + outputs = { + self, + nixpkgs, + }: let + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems (system: + f { + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + config.segger-jlink.acceptLicense = true; + config.permittedInsecurePackages = [ + "segger-jlink-qt4-796s" + ]; + }; + }); + in { + devShells = forEachSupportedSystem ({pkgs}: { + default = + pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + # stdenv = pkgs.clangStdenv; + # stdenv = pkgs.pkgsCross.arm-embedded.stdenv; + } + { + packages = with pkgs; + [ + pkgsCross.arm-embedded.stdenv.cc + segger-jlink + clang-tools + cmake + codespell + conan + cppcheck + ] + ++ ( + if system == "aarch64-darwin" + then [] + else [gdb] + ); + }; + }); + }; +}