Skip to content

Instantly share code, notes, and snippets.

View danidiaz's full-sized avatar

Daniel Díaz Carrete danidiaz

View GitHub Profile
@danidiaz
danidiaz / ifd1.nix
Last active August 5, 2023 16:40
ifd
# https://nixos.wiki/wiki/Import_From_Derivation
# https://discourse.nixos.org/t/how-to-import-a-derivation-with-import/15375
# https://nixos.org/manual/nix/stable/language/builtins#builtins-import
# https://nixos.org/manual/nix/stable/language/values.html#type-string
let
pkgs = import <nixpkgs> {};
derivation-to-import = pkgs.writeText "inner" "5";
imported-nix-value = import derivation-to-import;
in pkgs.writeText "foo" ''
The value from the inner derivation was: ${toString imported-nix-value}
@danidiaz
danidiaz / main.tf
Last active March 26, 2023 22:13
Hetzner terraform file
# https://developer.hashicorp.com/terraform/language/providers/requirements
# https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.36.2"
}
}
}
@danidiaz
danidiaz / flake.macos.nix
Last active May 10, 2023 10:59
My first Nix flake
{
# https://nix.dev/anti-patterns/language#unquoted-urls
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs, ... }@attrs:
# https://discourse.nixos.org/t/using-nixpkgs-legacypackages-system-vs-import/17462/5
# https://discourse.nixos.org/t/recommendations-for-use-of-flakes-input-follows/17413
let pkgs = nixpkgs.legacyPackages.aarch64-darwin;
in {
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-fmt.html
@danidiaz
danidiaz / shell.nix
Last active February 23, 2023 09:44
Wiremock shell.nix
# https://wiremock.org/docs/running-standalone/
# inspired by https://discourse.nixos.org/t/download-and-wrap-a-jar-extensively-documented-example/8049
{ pkgs ? import <nixpkgs> {} }:
let mywiremock =
pkgs.stdenv.mkDerivation rec {
name = "mywiremock";
version = "2.35.0";
# https://ryantm.github.io/nixpkgs/builders/fetchers/
src = pkgs.fetchurl {
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
-- https://discourse.haskell.org/t/enforcing-correct-api-usage-via-types/5798
module Main where
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE QualifiedDo #-}
{-# LANGUAGE ViewPatterns #-}
-- depends on the "dep-t" and "async" packages
module Main where
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
pkgs.glibcLocales
(pkgs.postgresql.withPackages (p: []))
pkgs.pgcli
];
shellHook = ''
StartPG(){
pg_ctl -w -l $PGDATA/log start
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
-- https://twitter.com/ChShersh/status/1544240982559948801
module Main where
import Data.Kind (Type)
import Data.RBR -- from package "red-black-record"
( Deletable (Delete),
FromList,