From 2cec871d533ce3b92aedb2abfca99262c1efbe5d Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Sun, 26 Dec 2021 11:47:16 -0800 Subject: [PATCH] Initial commit --- .envrc | 3 +++ .gitignore | 1 + checks/default.nix | 5 +++++ checks/nixpkgs-fmt.nix | 16 ++++++++++++++++ flake.lock | 43 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 ++++++++++++++++++++++++++++++ lib/default.nix | 3 +++ 7 files changed, 102 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 checks/default.nix create mode 100644 checks/nixpkgs-fmt.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 lib/default.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..0d21d96 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +watch_file flake.nix flake.lock *.nix **/*.nix + +eval "$(nix print-dev-env)" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6944e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result* diff --git a/checks/default.nix b/checks/default.nix new file mode 100644 index 0000000..043112b --- /dev/null +++ b/checks/default.nix @@ -0,0 +1,5 @@ +{ pkgs }: + +{ + nixpkgs-fmt = pkgs.callPackage ./nixpkgs-fmt.nix { }; +} diff --git a/checks/nixpkgs-fmt.nix b/checks/nixpkgs-fmt.nix new file mode 100644 index 0000000..a50a3f8 --- /dev/null +++ b/checks/nixpkgs-fmt.nix @@ -0,0 +1,16 @@ +{ lib +, nixpkgs-fmt +, runCommand +}: + +let + cleaned = lib.cleanSource ./..; + nixOnly = lib.sourceFilesBySuffices cleaned [ ".nix" ]; +in +runCommand "nixpkgs-fmt" +{ + nativeBuildInputs = [ nixpkgs-fmt ]; +} '' + nixpkgs-fmt --check ${nixOnly} + touch $out # it worked! +'' diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..45d8cae --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1640269308, + "narHash": "sha256-vBVwv3+kPrxbNyfo48cB5cc5/4tq5zlJGas/qw8XNBE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c408a087b4751c887e463e3848512c12017be25", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e0cc1ed --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils = { + url = "github:numtide/flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs@{ self, nixpkgs, utils, ... }: utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + + lib = import ./lib { + inherit pkgs; + }; + + checks = import ./checks { + inherit pkgs; + }; + in + { + inherit checks lib; + + devShell = pkgs.mkShell { + inputsFrom = builtins.attrValues checks; + }; + }); +} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..1638b53 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,3 @@ +{ pkgs }: + +{ }