Coder Social home page Coder Social logo

nix-cow's Introduction

nix-cow

This is a simple nix project to test declarative pulling from GitHub.

Adding a remote nix project to your system

To add this to your nix configuration, we first need to get the hash of the project. Run the following in a bash shell:

nix-prefetch-git --url https://github.com/jeslie0/nix-cow.git

You should get something similar to the following, but with different information.

| {               |                                                      |
| url             | https://github.com/jeslie0/nix-cow.git               |
| rev             | 8babdf1a33a34de5cd18c90e252eaca80c620bdd             |
| date            | 2021-12-03T14:16:55-05:00                            |
| path            | /nix/store/7whr8vaghjdmblz50rd1bxdfhc45dsdc-nix-cow  |
| sha256          | 0c5dgy3abmirpkzqnbpa9bxxy0gx40n0vxr2i2wkpf1nhkxc24b0 |
| fetchLFS        | false,                                               |
| fetchSubmodules | false,                                               |
| deepClone       | false,                                               |
| leaveDotGit     | false                                                |
| }               |                                                      |

We can read off the hash from the sha256 line. In you nix configuration file (or homemanager file) add the following to your installed programs list:

(import (fetchFromGitHub {
  owner = "jeslie0";
  repo = "nix-cow";
  rev = "8babdf1a33a34de5cd18c90e252eaca80c620bdd";
  sha256 = "0c5dgy3abmirpkzqnbpa9bxxy0gx40n0vxr2i2wkpf1nhkxc24b0";
}))

Then, reloading your configuration should add the repo to your system. You can test this by running the following:

cow

This project is just a shell script with cowsay as a runtime dependency. Note that Nix won’t install cowsay on your system, even though it is a dependency.

Adding a different commit

We don’t have to use the most recent commit of a remote project. We can specify the revision we would like for nix-prefetch-git to find out the correct sha256 hash. For example, we can take the initial commit of this project: (note that the rev can be found by clicking on the “rewind clock” button on GitHub)

nix-prefetch-git --url https://github.com/jeslie0/nix-cow.git --rev de73a93328bdcc7dc46c7051d6bf2f59c48e2bf9

This gives us the desired hash and we can use this in our configuration.

(import (fetchFromGitHub {
  owner = "jeslie0";
  repo = "nix-cow";
  rev = "de73a93328bdcc7dc46c7051d6bf2f59c48e2bf9";
  sha256 = "1qiw2xaajb8yw2rhdhddxx6pymf21mf5hbwclh7a0gi1wdf16ri3";
}))

Flakes

This project is also a nix flake! This makes it very easy to use. You can run the program without even downloading this repository!

nix run github:jeslie0/nix-cow

To add it to a nix flake system, add this flake to your inputs:

inputs.nix-cow.url = "github:jeslie0/nix-cow";

You can then include it in your configuration as:

environment.systemPackages = with pkgs;
  [ ...
    self.inputs.nix-cow.defaultPackage.${system}
    ...
  ];

nix-cow's People

Contributors

jeslie0 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.