From 78fb95c8cf8a73cc973f8e6c5b336d010b9b9016 Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Tue, 1 Jul 2025 10:41:07 +0200 Subject: [PATCH] chore: upgrade from nix-shell to nix flake nix flakes are our preferred way of shipping dev shells across all repos at meshcloud --- default.nix | 54 ------------------------------------- flake.lock | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 44 ++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 54 deletions(-) delete mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 030695daa..000000000 --- a/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ pkgs ? import { } }: - -# Fixing packages -# 1. Find out which package is needed under https://search.nixos.org/packages -# 2. Search package under https://lazamar.co.uk/nix-versions/ and pick version -# 3. Extract the packages as per instructions -# 4. Add packages in pkgs.mkShell -let - pkgs_fix_dhall = import - (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/d86bcbb415938888e7f606d55c52689aec127f43.tar.gz"; - }) - { }; - - fix_dhall = pkgs_fix_dhall.haskellPackages.dhall_1_41_1; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall - fix_dhall_docs = pkgs_fix_dhall.haskellPackages.dhall-docs; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall-docs - fix_dhall_json = pkgs_fix_dhall.haskellPackages.dhall-json_1_7_10; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall-json - - pkgs_fix_dhall_lsp = import - (builtins.fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/89f196fe781c53cb50fef61d3063fa5e8d61b6e5.tar.gz"; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall-lsp-server - }) - { }; - - fix_dhall_lsp = pkgs_fix_dhall_lsp.dhall-lsp-server; -in - -pkgs.mkShell { - NIX_SHELL = "meshcloud-shell"; - shellHook = '' - echo starting meshcloud developer shell - - # this is where we install custom versions of dhall that are not on nixpkgs - export PATH="$PWD/.local/bin:$PATH" - ''; - - buildInputs = [ - pkgs.opentofu - pkgs.nodejs-18_x - (pkgs.yarn.override { - nodejs = pkgs.nodejs-18_x; - }) - - # NOTE: these are most likely present the wrong version on your package registry, install them into - # ./local/bin with these instructions https://www.notion.so/meshcloud/Dhall-for-non-Haskell-Gurus-1f822f0a07f34528a89c5d4e2be3e519#1ba5901640e741e0bf8a843828e4333e - # dhall (meshStack config model) - fix_dhall - fix_dhall_docs - (fix_dhall_json.override { - dhall = fix_dhall; - }) - fix_dhall_lsp - ]; -} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..2e1813854 --- /dev/null +++ b/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "dhall-pkgs": { + "locked": { + "lastModified": 1659391243, + "narHash": "sha256-TDvJla9KHwicHyPOH8J6vAOtuRYUZdWXrp4XrjsR83M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d86bcbb415938888e7f606d55c52689aec127f43", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d86bcbb415938888e7f606d55c52689aec127f43", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751048012, + "narHash": "sha256-MYbotu4UjWpTsq01wglhN5xDRfZYLFtNk7SBY0BcjkU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a684c58d46ebbede49f280b653b9e56100aa3877", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "dhall-pkgs": "dhall-pkgs", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..ce7afb56d --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "A Nix flake for the meshStack docs developer shell"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-24.11"; + flake-utils.url = "github:numtide/flake-utils"; + + # Fixing packages + # 1. Find out which package is needed under https://search.nixos.org/packages + # 2. Search package under https://lazamar.co.uk/nix-versions/ and pick version + # 3. Extract the packages as per instructions + # 4. Add packages in pkgs.mkShell + dhall-pkgs = { + url = "github:NixOS/nixpkgs/d86bcbb415938888e7f606d55c52689aec127f43"; + }; + }; + + outputs = { self, nixpkgs, flake-utils, dhall-pkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + dhallpkgs = import dhall-pkgs { inherit system; }; + + fix_dhall = dhallpkgs.haskellPackages.dhall_1_41_1; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall + fix_dhall_docs = dhallpkgs.haskellPackages.dhall-docs; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall-docs + fix_dhall_json = dhallpkgs.haskellPackages.dhall-json_1_7_10; # https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=dhall-json + fix_dhall_lsp = dhallpkgs.dhall-lsp-server; + + core_packages = [ + # node / typescript (meshPanel, utilities eetc.) + pkgs.nodejs_22 + (pkgs.yarn.override { + nodejs = pkgs.nodejs_22; + }) + ]; + in + { + devShells.default = pkgs.mkShell { + name = "shell with all basic runtimes and tools"; + packages = core_packages; + }; + } + ); +}