From f4c39ef3255da75dc116a9c8c7358dae4833dbfb Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Tue, 12 Sep 2023 11:31:06 -0400 Subject: [PATCH] bring in flake-utils --- TODO | 10 ++++++-- flake.lock | 69 +++++++++++++++++++++++++++++++++++++++++++++++------- flake.nix | 20 +++++++++++----- hello.c | 4 ++-- 4 files changed, 84 insertions(+), 19 deletions(-) diff --git a/TODO b/TODO index cf131dd..20f44b3 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,13 @@ * add second build target `world.c` * add GitHub workflow to build all targets, upload/publish all artifacts + * deb, rpm, tgz of source + * Docker container on DockerHub, GitHub Container Repository (ghcr.io) + * containers could have multiple tags as in `latest` and `1.0.0` * add Nix Flake * devshell * direnv/envrc -* build windows - +* build windows MSYS2 +* formatting +* lint +* security audits +* Gitpod diff --git a/flake.lock b/flake.lock index 4301e9d..9004631 100644 --- a/flake.lock +++ b/flake.lock @@ -1,24 +1,75 @@ { "nodes": { - "nixpkgs": { + "flake-compat": { + "flake": false, "locked": { - "lastModified": 1659914493, - "narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "nixos-21.05", - "type": "indirect" + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1694532420, + "narHash": "sha256-eOebmMxt5B8nmW5u8P6BkYR9tLwcyq74fnsBBZmBSNQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "80616a47486f85bbe60650b6770cf8129333a26f", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" } }, "root": { "inputs": { + "flake-compat": "flake-compat", + "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", diff --git a/flake.nix b/flake.nix index 2d4bb34..a4bd46d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,16 @@ description = "An over-engineered Hello World in C"; # Nixpkgs / NixOS version to use. - inputs.nixpkgs.url = "nixpkgs/nixos-21.05"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs, flake-utils, flake-compat }: let # to work with older version of flakes @@ -36,6 +43,7 @@ src = ./.; nativeBuildInputs = [ autoreconfHook ]; + enableParallelBuilding = true; }; }; @@ -46,12 +54,12 @@ inherit (nixpkgsFor.${system}) hello; }); - # The default package for 'nix build'. This makes sense if the - # flake provides only one package or there is a clear "main" - # package. + # The default package for 'nix build'. This makes sense if the flake + # provides only one package or there is a clear "main" package. defaultPackage = forAllSystems (system: self.packages.${system}.hello); - # A NixOS module, if applicable (e.g. if the package provides a system service). + # A NixOS module, if applicable (e.g. if the package provides a system + # service). nixosModules.hello = { pkgs, ... }: { diff --git a/hello.c b/hello.c index d67cd5d..cb63c86 100644 --- a/hello.c +++ b/hello.c @@ -1,6 +1,6 @@ #include "stdio.h" -int main(int argc, char * * argv) +int main(int argc, char **argv) { - printf("Hello Nixers!\n"); + printf("Hello, world!\n"); }