From c5c4d4aba7583036a4caf9f87cc1f1442186a243 Mon Sep 17 00:00:00 2001 From: maralorn Date: Mon, 16 Jan 2023 00:30:25 +0100 Subject: [PATCH] Flakify --- .envrc | 2 +- flake.lock | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 46 ++++++++++++++++++ shell.nix | 5 -- test.nix | 16 ------- 5 files changed, 185 insertions(+), 22 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix delete mode 100644 test.nix diff --git a/.envrc b/.envrc index 4a4726a5..c4b17d79 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use_nix +use_flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..d89e4621 --- /dev/null +++ b/flake.lock @@ -0,0 +1,138 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673362319, + "narHash": "sha256-Pjp45Vnj7S/b3BRpZEVfdu8sqqA6nvVjvYu59okhOyI=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "82c16f1682cf50c01cb0280b38a1eed202b3fe9f", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1673606088, + "narHash": "sha256-wdYD41UwNwPhTdMaG0AIe7fE1bAdyHe6bB4HLUqUvck=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "37b97ae3dd714de9a17923d004a2c5b5543dfa6d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1671271954, + "narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1673627351, + "narHash": "sha256-oppRxEg/7ICcG67ErBvu1UlXt3su6zMcNoQmKaHPs5I=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "496e4505c2ddf5f205242eae8064d7d89cd976c0", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "pre-commit-hooks-nix": "pre-commit-hooks-nix" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..e3746232 --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "maralorns configuration"; + + inputs = { + flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; + pre-commit-hooks-nix = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + }; + + outputs = inputs @ { + nixpkgs, + flake-parts, + ... + }: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + inputs.pre-commit-hooks-nix.flakeModule + ]; + systems = ["x86_64-linux"]; + perSystem = { + self', + pkgs, + config, + ... + }: { + devShells.default = pkgs.mkShell { + shellHook = config.pre-commit.installationScript; + }; + pre-commit = { + check.enable = true; + settings.hooks = { + hlint.enable = true; + alejandra.enable = true; + nix-linter.enable = false; # Too many false positives for now + statix.enable = true; + fourmolu.enable = true; + shellcheck.enable = true; + }; + }; + }; + }; +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 88a510ea..00000000 --- a/shell.nix +++ /dev/null @@ -1,5 +0,0 @@ -(import (import ./nix/sources.nix).nixos-stable {}).mkShell { - shellHook = '' - ${(import ./test.nix).pre-commit-check.shellHook} - ''; -} diff --git a/test.nix b/test.nix deleted file mode 100644 index 0d9e2077..00000000 --- a/test.nix +++ /dev/null @@ -1,16 +0,0 @@ -let - commit = (builtins.fromJSON (builtins.readFile ./nix/sources.json))."pre-commit-hooks.nix".rev; - nix-pre-commit-hooks = builtins.getFlake "github:cachix/pre-commit-hooks.nix/${commit}"; -in { - pre-commit-check = nix-pre-commit-hooks.lib.x86_64-linux.run { - src = ./.; - hooks = { - hlint.enable = true; - alejandra.enable = true; - nix-linter.enable = false; # Too many false positives for now - statix.enable = true; - fourmolu.enable = true; - shellcheck.enable = true; - }; - }; -}