Skip to content

feat(nix): add mkShell and flake #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions snippets/nix.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,86 @@
],
"description": "Nixpkgs' stdenv.mkDerivation template"
},
"pkgs.mkShell": {
"prefix": "mks",
"body": [
"pkgs.mkShell {",
" shellHook = ''",
" $1",
" '';",
"",
" env = {",
" $2",
" };",
"",
" packages = [",
" $3",
" ];",
"}"
],
"description": "mkShell template"
},
"flake-parts": {
"prefix": "flakeparts",
"body": [
"{",
" description = \"${1:A flake}\";",
"",
" inputs = {",
" nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";",
" flake-parts.url = \"github:hercules-ci/flake-parts\";",
" };",
"",
" outputs =",
" inputs@{ flake-parts, ... }:",
" flake-parts.lib.mkFlake { inherit inputs; } {",
" imports = [",
" $2",
" ];",
" systems = [",
" \"x86_64-linux\"",
" \"aarch64-linux\"",
" \"aarch64-darwin\"",
" \"x86_64-darwin\"",
" ];",
" perSystem =",
" {",
" config,",
" pkgs,",
" system,",
" ...",
" }:",
" {",
" $3",
" };",
" flake = {",
" $4",
" };",
" };",
"}"
],
"description": "simple flake template with flake-parts"
},
"flake-utils": {
"prefix": "flakeutils",
"body": [
"{",
" description = \"${1:A flake}\";",
"",
" inputs = {",
" nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";",
" flake-utils.url = \"github:numtide/flake-utils\";",
Copy link
Contributor

@Eveeifyeve Eveeifyeve May 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would not use flake-utils as it's not module system compliant, but I would say split up to flake-parts and flake-utils as separate snippets and do the default or just remove flake-utils from this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about lib.genAttrs <SYSTEMS> (system: {}) so we'd only need nixpkgs? We could add a different flake-parts snippet but that might get out of hand quite quickly as flake.parts is quite the rabbit hole.

Copy link
Contributor

@Eveeifyeve Eveeifyeve Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say probably best to create one with all systems, flake utils and flake parts.

" $2",
" };",
"",
" outputs = inputs @ { self, nixpkgs, flake-utils, ... }: ",
" flake-utils.lib.eachDefaultSystem (system: {",
" $3",
" });",
"}"
],
"description": "simple flake template with flake-utils"
},
"meta": {
"prefix": "meta",
"body": [
Expand Down