From 9ac4b419e057f5909808f9e0604769514d7469e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20J=C3=B6rg?= Date: Mon, 5 Aug 2024 19:07:19 +0200 Subject: [PATCH] feat: Add nix flake with python and dependencies --- .envrc | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5ccb3d8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722730825, + "narHash": "sha256-X6U+w8qFBuGPCYrZzc9mpN34aRjQ8604MonpBUkj908=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f3834de3782b82bfc666abf664f946d0e7d1f116", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "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..ea48790 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + description = "Masterblaser Flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + }; + + outputs = { + self, + nixpkgs, + }: let + # Helpers for producing system-specific outputs + supportedSystems = ["x86_64-linux" "aarch64-darwin"]; + forEachSupportedSystem = f: + nixpkgs.lib.genAttrs supportedSystems (system: + f { + pkgs = import nixpkgs {inherit system;}; + }); + in { + # Development environments + devShells = forEachSupportedSystem ({pkgs}: { + default = pkgs.mkShell { + # Pinned packages available in the environment + packages = with pkgs; [ + python311 + (with python311Packages; [ + aiohttp + dateutils + ]) + ]; + + # Environment variables + env = { + ACCESS_TOKEN = ""; + ORG_ID = ""; + ORG_NAME = ""; + MB_BASE_URL = "https://app.bedriftsligaen.no/api"; + NUMBER_OF_MEMBERS = ""; + TEAM_NAME = ""; + }; + + # A hook run every time you enter the environment + # Can load variables from `.env` file + shellHook = '' + set -a; source .env; set +a + ''; + }; + }); + }; +}